Skip to content

Commit

Permalink
libraries release version 1.0.68 unstable; thirdparty updates
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasWBartels committed Oct 17, 2017
1 parent 63e7670 commit 2dee908
Show file tree
Hide file tree
Showing 86 changed files with 735 additions and 185 deletions.
2 changes: 1 addition & 1 deletion commons/advanced/Commons_Advanced/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-maven-advanced</artifactId>
<version>1.0.64</version>
<version>1.0.68</version>
</parent>

<scm>
Expand Down
2 changes: 1 addition & 1 deletion commons/advanced/Commons_Http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-maven-advanced</artifactId>
<version>1.0.64</version>
<version>1.0.68</version>
</parent>

<scm>
Expand Down
2 changes: 1 addition & 1 deletion commons/advanced/Commons_Image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-maven-advanced</artifactId>
<version>1.0.64</version>
<version>1.0.68</version>
</parent>

<scm>
Expand Down
11 changes: 9 additions & 2 deletions commons/advanced/Commons_Json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-maven-advanced</artifactId>
<version>1.0.64</version>
<version>1.0.68</version>
</parent>

<scm>
Expand All @@ -27,6 +27,13 @@
<version>${net.anwiba.commons.version}</version>
</dependency>

<dependency>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-resource</artifactId>
<version>${net.anwiba.commons.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-reflaction</artifactId>
Expand Down Expand Up @@ -137,4 +144,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -68,7 +69,8 @@ protected List<T> _unmarshal(final InputStream stream) throws IOException, E {
final ObjectReader reader = this.mapper.readerFor(this.clazz).with(injectableValues);
final JsonToken token = parser.nextToken();
if (token != JsonToken.START_ARRAY) {
return reader.readValue(parser);
final T value = reader.readValue(parser);
return Arrays.asList(value);
}
// and then each time, advance to opening START_OBJECT
final List<T> results = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ public JsonObjectUnmarshaller(final Class<T> clazz) {
}

public JsonObjectUnmarshaller(final Class<T> clazz, final Map<String, Object> injectionValues) {
super(clazz, Void.class, injectionValues, new IJsonObjectMarshallingExceptionFactory<Void, IOException>() {

@Override
public IOException create(final Void response) {
throw new RuntimeException("Unreachable code reached"); //$NON-NLS-1$
}
super(clazz, Void.class, injectionValues, response -> {
throw new RuntimeException("Unreachable code reached"); //$NON-NLS-1$
});
}
}
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$
});
}

}
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);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@JssdFactory
@JssdFactory(type="typeinfo",types="booleanProperty:boolean,integerProperty:integer,numberProperty:number,objectProperty:object,stringProperty:string")
@JssdIgnoreUnknownMember
{
"name": <java.lang.String> null,
"title": <java.lang.String> null,
Expand Down
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));
}

}
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));
}

}
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;

}
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"}
}
}
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"}
}
}
]
2 changes: 1 addition & 1 deletion commons/advanced/Commons_Message/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-maven-advanced</artifactId>
<version>1.0.64</version>
<version>1.0.68</version>
</parent>

<scm>
Expand Down
2 changes: 1 addition & 1 deletion commons/advanced/Commons_Model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-maven-advanced</artifactId>
<version>1.0.64</version>
<version>1.0.68</version>
</parent>

<scm>
Expand Down
2 changes: 1 addition & 1 deletion commons/advanced/Commons_NLS/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-maven-advanced</artifactId>
<version>1.0.64</version>
<version>1.0.68</version>
</parent>

<scm>
Expand Down
2 changes: 1 addition & 1 deletion commons/advanced/Commons_Preferences/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-maven-advanced</artifactId>
<version>1.0.64</version>
<version>1.0.68</version>
</parent>

<scm>
Expand Down
2 changes: 1 addition & 1 deletion commons/advanced/Commons_Process/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-maven-advanced</artifactId>
<version>1.0.64</version>
<version>1.0.68</version>
</parent>

<scm>
Expand Down
Loading

0 comments on commit 2dee908

Please sign in to comment.