-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libraries release version 1.0.68 unstable; thirdparty updates
- Loading branch information
1 parent
63e7670
commit 2dee908
Showing
86 changed files
with
735 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
.../advanced/Commons_Json/src/main/java/net/anwiba/commons/json/JsonObjectsUnmarshaller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2012 by Andreas W. Bartels (bartels@anwiba.net) | ||
package net.anwiba.commons.json; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import net.anwiba.commons.lang.map.HasMapBuilder; | ||
|
||
public class JsonObjectsUnmarshaller<T> extends AbstractJsonObjectsUnmarshaller<T, Void, IOException> { | ||
|
||
public JsonObjectsUnmarshaller(final Class<T> clazz) { | ||
this(clazz, new HasMapBuilder<String, Object>().build()); | ||
} | ||
|
||
public JsonObjectsUnmarshaller(final Class<T> clazz, final Map<String, Object> injectionValues) { | ||
super(clazz, Void.class, injectionValues, response -> { | ||
throw new RuntimeException("Unreachable code reached"); //$NON-NLS-1$ | ||
}); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...ed/Commons_Json/src/main/java/net/anwiba/commons/json/JsonObjectsUnmarshallerBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* #%L | ||
* anwiba commons advanced | ||
* %% | ||
* Copyright (C) 2007 - 2016 Andreas Bartels | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 2.1 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
* #L% | ||
*/ | ||
|
||
package net.anwiba.commons.json; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class JsonObjectsUnmarshallerBuilder<T> { | ||
|
||
private final Class<T> clazz; | ||
final Map<String, Object> injectionValues = new HashMap<>(); | ||
|
||
public JsonObjectsUnmarshallerBuilder(final Class<T> clazz) { | ||
this.clazz = clazz; | ||
} | ||
|
||
public <C> JsonObjectsUnmarshallerBuilder<T> addInjectionValues(final String property, final C value) { | ||
this.injectionValues.put(property, value); | ||
return this; | ||
} | ||
|
||
public JsonObjectsUnmarshaller<T> build() { | ||
return new JsonObjectsUnmarshaller<>(this.clazz, this.injectionValues); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
...s/advanced/Commons_Json/src/main/schema/net/anwiba/commons/json/schema/v1_0/property.jssd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...vanced/Commons_Json/src/test/java/net/anwiba/commons/json/JsonObjectUnmarshallerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* #%L | ||
* | ||
* %% | ||
* Copyright (C) 2007 - 2017 Andreas W. Bartels (bartels@anwiba.de) | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 2.1 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
* #L% | ||
*/ | ||
package net.anwiba.commons.json; | ||
|
||
import static org.hamcrest.CoreMatchers.*; | ||
import static org.junit.Assert.*; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.Test; | ||
|
||
import net.anwiba.commons.json.schema.v1_0.ObjectProperty; | ||
import net.anwiba.commons.json.schema.v1_0.Property; | ||
|
||
public class JsonObjectUnmarshallerTest { | ||
|
||
@Test | ||
public void object() throws IOException { | ||
final JsonObjectUnmarshaller<ObjectProperty> unmarshaller = new JsonObjectUnmarshallerBuilder<>( | ||
ObjectProperty.class).build(); | ||
final ObjectProperty response = unmarshaller.unmarshal(TestResources.object); | ||
assertThat(response, notNullValue()); | ||
assertThat(response, instanceOf(ObjectProperty.class)); | ||
} | ||
|
||
@Test | ||
public void property() throws IOException { | ||
final JsonObjectUnmarshaller<Property> unmarshaller = new JsonObjectUnmarshallerBuilder<>(Property.class).build(); | ||
final Property response = unmarshaller.unmarshal(TestResources.object); | ||
assertThat(response, notNullValue()); | ||
assertThat(response, instanceOf(ObjectProperty.class)); | ||
} | ||
|
||
} |
83 changes: 83 additions & 0 deletions
83
...anced/Commons_Json/src/test/java/net/anwiba/commons/json/JsonObjectsUnmarshallerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* #%L | ||
* | ||
* %% | ||
* Copyright (C) 2007 - 2017 Andreas W. Bartels (bartels@anwiba.de) | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 2.1 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
* #L% | ||
*/ | ||
package net.anwiba.commons.json; | ||
|
||
import static org.hamcrest.CoreMatchers.*; | ||
import static org.junit.Assert.*; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import net.anwiba.commons.json.schema.v1_0.ObjectProperty; | ||
import net.anwiba.commons.json.schema.v1_0.Property; | ||
|
||
public class JsonObjectsUnmarshallerTest { | ||
|
||
@Test | ||
public void property() throws IOException { | ||
final JsonObjectsUnmarshaller<Property> unmarshaller = new JsonObjectsUnmarshallerBuilder<>(Property.class).build(); | ||
final List<Property> response = unmarshaller.unmarshal(TestResources.object); | ||
assertThat(response, notNullValue()); | ||
assertThat(response.size(), equalTo(1)); | ||
assertThat(response.get(0), notNullValue()); | ||
assertThat(response.get(0), instanceOf(ObjectProperty.class)); | ||
} | ||
|
||
@Test | ||
public void object() throws IOException { | ||
final JsonObjectsUnmarshaller<ObjectProperty> unmarshaller = new JsonObjectsUnmarshallerBuilder<>( | ||
ObjectProperty.class).build(); | ||
final List<ObjectProperty> response = unmarshaller.unmarshal(TestResources.object); | ||
assertThat(response, notNullValue()); | ||
assertThat(response.size(), equalTo(1)); | ||
assertThat(response.get(0), notNullValue()); | ||
assertThat(response.get(0), instanceOf(ObjectProperty.class)); | ||
} | ||
|
||
@Test | ||
public void properties() throws IOException { | ||
final JsonObjectsUnmarshaller<Property> unmarshaller = new JsonObjectsUnmarshallerBuilder<>(Property.class).build(); | ||
final List<Property> response = unmarshaller.unmarshal(TestResources.objects); | ||
assertThat(response, notNullValue()); | ||
assertThat(response.size(), equalTo(2)); | ||
assertThat(response.get(0), notNullValue()); | ||
assertThat(response.get(0), instanceOf(ObjectProperty.class)); | ||
assertThat(response.get(1), notNullValue()); | ||
assertThat(response.get(1), instanceOf(ObjectProperty.class)); | ||
} | ||
|
||
@Test | ||
public void objects() throws IOException { | ||
final JsonObjectsUnmarshaller<ObjectProperty> unmarshaller = new JsonObjectsUnmarshallerBuilder<>( | ||
ObjectProperty.class).build(); | ||
final List<ObjectProperty> response = unmarshaller.unmarshal(TestResources.objects); | ||
assertThat(response, notNullValue()); | ||
assertThat(response.size(), equalTo(2)); | ||
assertThat(response.get(0), notNullValue()); | ||
assertThat(response.get(0), instanceOf(ObjectProperty.class)); | ||
assertThat(response.get(1), notNullValue()); | ||
assertThat(response.get(1), instanceOf(ObjectProperty.class)); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
commons/advanced/Commons_Json/src/test/java/net/anwiba/commons/json/TestResources.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.anwiba.commons.json; | ||
|
||
import net.anwiba.commons.resource.annotation.Location; | ||
import net.anwiba.commons.resource.reflaction.AbstractResourceFactory; | ||
|
||
public class TestResources extends AbstractResourceFactory { | ||
|
||
static { | ||
initialize(TestResources.class); | ||
} | ||
|
||
@Location("object.json") | ||
public static String object; | ||
|
||
@Location("objects.json") | ||
public static String objects; | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
commons/advanced/Commons_Json/src/test/resources/net/anwiba/commons/json/object.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "object", | ||
"name": "size", | ||
"properties" : { | ||
"value": {"type": "integer", "name": "value"}, | ||
"unit": {"type": "string", "name": "unit"} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
commons/advanced/Commons_Json/src/test/resources/net/anwiba/commons/json/objects.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[ | ||
{ | ||
"type": "object", | ||
"name": "size", | ||
"properties" : { | ||
"value": {"type": "integer", "name": "value"}, | ||
"unit": {"type": "string", "name": "unit"} | ||
} | ||
}, | ||
{ | ||
"type": "object", | ||
"name": "description", | ||
"properties" : { | ||
"value": {"type": "string", "name": "value"}, | ||
"language": {"type": "string", "name": "language"} | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.