event);
33 | }
34 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/CollectionProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.kscs.util.jaxb;
26 |
27 | import java.util.List;
28 |
29 | /**
30 | * Represents the instance of a {@link CollectionPropertyInfo}, i.e. represents the
31 | * property meta information along with its value, and enables to get and set the value
32 | */
33 | public class CollectionProperty extends Property {
34 | public CollectionProperty(final CollectionPropertyInfo info, final I owner) {
35 | super(info, owner);
36 | }
37 |
38 | @Override
39 | public CollectionPropertyInfo getInfo() {
40 | return (CollectionPropertyInfo)super.getInfo();
41 | }
42 |
43 | @Override
44 | public List get() {
45 | return getInfo().get(getOwner());
46 | }
47 |
48 | public void set(final List
values) {
49 | getInfo().set(getOwner(), values);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/CollectionPropertyInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.kscs.util.jaxb;
26 |
27 | import java.util.List;
28 |
29 | import javax.xml.namespace.QName;
30 |
31 | /**
32 | * Represents a multi-value property of a JAXB-generated java class.
33 | */
34 | public abstract class CollectionPropertyInfo extends PropertyInfo {
35 | protected CollectionPropertyInfo(final String propertyName, final Class declaringClass, final Class
declaredType, final boolean collection, final P defaultValue, final QName schemaName, final QName schemaType, final boolean attribute) {
36 | super(propertyName, declaringClass, declaredType, collection, defaultValue, schemaName, schemaType, attribute);
37 | }
38 |
39 | @Override
40 | public abstract List
get(final I instance);
41 |
42 | public abstract void set(final I instance, final List
values);
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/Copyable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | package com.kscs.util.jaxb;
25 |
26 | /**
27 | * Contract for objects that can be copied,
28 | * similar to the "Object.clone()" contract,
29 | * but only available on objects explicitly implementing
30 | * this interface.
31 | */
32 | public interface Copyable> {
33 | T createCopy();
34 | }
35 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/IndirectCollectionProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.kscs.util.jaxb;
26 |
27 | import java.util.List;
28 |
29 | import jakarta.xml.bind.JAXBElement;
30 |
31 | /**
32 | * Represents the instance of a {@link IndirectCollectionPropertyInfo}, i.e. represents the
33 | * property meta information along with its value, and enables to get an d set the value
34 | */
35 | public class IndirectCollectionProperty extends Property {
36 | public IndirectCollectionProperty(final PropertyInfo info, final I owner) {
37 | super(info, owner);
38 | }
39 |
40 | @Override
41 | public IndirectCollectionPropertyInfo getInfo() {
42 | return (IndirectCollectionPropertyInfo)super.getInfo();
43 | }
44 |
45 | @Override
46 | public List> get() {
47 | return getInfo().get(getOwner());
48 | }
49 |
50 | public void set(final List> values) {
51 | getInfo().set(getOwner(), values);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/IndirectCollectionPropertyInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.kscs.util.jaxb;
26 |
27 | import java.util.List;
28 |
29 | import jakarta.xml.bind.JAXBElement;
30 | import javax.xml.namespace.QName;
31 |
32 | /**
33 | * Represents a multi-value property of a JAXB-generated java class where the individual values are wrapped in
34 | * a {@link JAXBElement} instance.
35 | */
36 | public abstract class IndirectCollectionPropertyInfo extends PropertyInfo {
37 | protected IndirectCollectionPropertyInfo(final String propertyName, final Class declaringClass, final Class declaredType, final boolean collection, final P defaultValue, final QName schemaName, final QName schemaType, final boolean attribute) {
38 | super(propertyName, declaringClass, declaredType, collection, defaultValue, schemaName, schemaType, attribute);
39 | }
40 |
41 | @Override
42 | public abstract List> get(final I i) ;
43 |
44 | public abstract void set(final I instance, final List> values);
45 | }
46 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/IndirectPrimitiveCollectionProperty.java:
--------------------------------------------------------------------------------
1 | package com.kscs.util.jaxb;
2 |
3 | import java.util.List;
4 |
5 | import jakarta.xml.bind.JAXBElement;
6 |
7 | /**
8 | * Represents the instance of a {@link IndirectPrimitiveCollectionPropertyInfo}, i.e. represents the
9 | * property meta information along with its value, and enables to get an d set the value
10 | */
11 | public class IndirectPrimitiveCollectionProperty extends Property {
12 | public IndirectPrimitiveCollectionProperty(final PropertyInfo info, final I owner) {
13 | super(info, owner);
14 | }
15 |
16 | @Override
17 | public IndirectPrimitiveCollectionPropertyInfo getInfo() {
18 | return (IndirectPrimitiveCollectionPropertyInfo)super.getInfo();
19 | }
20 |
21 | @Override
22 | public List> get() {
23 | return getInfo().get(getOwner());
24 | }
25 |
26 | public void set(final List> values) {
27 | getInfo().set(getOwner(), values);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/IndirectPrimitiveCollectionPropertyInfo.java:
--------------------------------------------------------------------------------
1 | package com.kscs.util.jaxb;
2 |
3 | import java.util.List;
4 |
5 | import javax.xml.namespace.QName;
6 |
7 | import jakarta.xml.bind.JAXBElement;
8 |
9 | /**
10 | * Represents a multi-value property of a JAXB-generated java class where the individual values are wrapped in
11 | * a {@link JAXBElement} instance, and the individual values are of a java primitive type.
12 | */
13 | public abstract class IndirectPrimitiveCollectionPropertyInfo extends PropertyInfo {
14 | protected IndirectPrimitiveCollectionPropertyInfo(final String propertyName, final Class declaringClass, final Class declaredType, final boolean collection, final P defaultValue, final QName schemaName, final QName schemaType, final boolean attribute) {
15 | super(propertyName, declaringClass, declaredType, collection, defaultValue, schemaName, schemaType, attribute);
16 | }
17 |
18 | @Override
19 | public abstract List> get(final I i) ;
20 |
21 | public abstract void set(final I instance, final List> values);
22 | }
23 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/ItemProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.kscs.util.jaxb;
26 |
27 | /**
28 | * @author Mirko Klemm 2015-10-16
29 | */
30 | public class ItemProperty extends Property {
31 | final P value;
32 | final int index;
33 |
34 | public ItemProperty(final CollectionPropertyInfo info, final I owner, final P value, final int index) {
35 | super(info, owner);
36 | this.value = value;
37 | this.index = index;
38 | }
39 |
40 | @Override
41 | public CollectionPropertyInfo getInfo() {
42 | return (CollectionPropertyInfo)super.getInfo();
43 | }
44 |
45 | @Override
46 | public P get() {
47 | return this.value;
48 | }
49 |
50 | public int getIndex() {
51 | return this.index;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/PartialCopyable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | package com.kscs.util.jaxb;
25 |
26 | /**
27 | * Contract for objects that can be copied partially,
28 | * i.e. by explicitly excluding or including specified
29 | * branches of the object tree.
30 | */
31 | public interface PartialCopyable> {
32 |
33 | /**
34 | * Clones this instances partially, the parts
35 | * will be defined by propertyTree
36 | *
37 | * @param propertyTree Defines which parts of the object tree will be cloned or excluded
38 | * @param propertyTreeUse Defines how the clone graph will be used: To include or to exclude properties.
39 | * @return A copy of the original object.
40 | */
41 | T createCopy(final PropertyTree propertyTree, final PropertyTreeUse propertyTreeUse);
42 |
43 | /**
44 | * Clones this instances partially, the parts
45 | * to be EXCLUDED will be defined by propertyTree
46 | *
47 | * @param propertyTree Defines which parts of the object tree will be excluded
48 | * @return A copy of the original object.
49 | */
50 | T copyExcept(final PropertyTree propertyTree);
51 |
52 | /**
53 | * Clones this instances partially, the parts
54 | * to be INCLUDED will be defined by propertyTree
,
55 | * all other parts will be excluded.
56 | *
57 | * @param propertyTree Defines which parts of the object tree will be included in the clone
58 | * @return A copy of the original object.
59 | */
60 | T copyOnly(final PropertyTree propertyTree);
61 | }
62 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/Property.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.kscs.util.jaxb;
26 |
27 | /**
28 | * Abstract base class for all property instances of a JAXB-generated class's instances.
29 | */
30 | public abstract class Property {
31 | private final PropertyInfo info;
32 | private final I owner;
33 |
34 | protected Property(final PropertyInfo info, final I owner) {
35 | this.info = info;
36 | this.owner = owner;
37 | }
38 |
39 | public PropertyInfo getInfo() {
40 | return this.info;
41 | }
42 |
43 | public I getOwner() {
44 | return this.owner;
45 | }
46 |
47 | public Object get() {
48 | return this.info.get(this.owner);
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/PropertyInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | package com.kscs.util.jaxb;
25 |
26 | import javax.xml.namespace.QName;
27 |
28 | /**
29 | * Represents a property of a JAXB-generated class.
30 | * @param The type declaring the property
31 | * @param The type of the property
32 | */
33 | public abstract class PropertyInfo {
34 | public final String propertyName;
35 | public final Class
declaredType;
36 | public final Class declaringClass;
37 | public final boolean collection;
38 | public final P defaultValue;
39 | public final QName schemaType;
40 | public final boolean attribute;
41 | public final QName schemaName;
42 |
43 | protected PropertyInfo(final String propertyName, final Class declaringClass, final Class
declaredType, final boolean collection, final P defaultValue, final QName schemaName, final QName schemaType, final boolean attribute) {
44 | this.propertyName = propertyName;
45 | this.declaredType = declaredType;
46 | this.declaringClass = declaringClass;
47 | this.collection = collection;
48 | this.defaultValue = defaultValue;
49 | this.schemaType = schemaType;
50 | this.attribute = attribute;
51 | this.schemaName = schemaName;
52 | }
53 |
54 | public abstract Object get(final I instance);
55 |
56 | @Override
57 | public boolean equals(final Object o) {
58 | if (this == o) return true;
59 | if (!(o instanceof PropertyInfo)) return false;
60 | final PropertyInfo, ?> that = (PropertyInfo, ?>)o;
61 | if (!this.propertyName.equals(that.propertyName)) return false;
62 | return declaringClass.equals(that.declaringClass);
63 | }
64 |
65 | @Override
66 | public int hashCode() {
67 | int result = this.propertyName.hashCode();
68 | result = 31 * result + this.declaringClass.hashCode();
69 | return result;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/PropertyTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | package com.kscs.util.jaxb;
25 |
26 | /**
27 | * @author mirko 2014-04-07
28 | */
29 | public interface PropertyTransformer {
30 | TProperty transform(final PropertyInfo propertyInfo, final TInstance sourceInstance, final TProperty sourcePropertyValue);
31 | }
32 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/PropertyTreeUse.java:
--------------------------------------------------------------------------------
1 | package com.kscs.util.jaxb;
2 |
3 | /**
4 | * @author mirko 2014-06-04
5 | */
6 | public enum PropertyTreeUse {
7 | INCLUDE,
8 | EXCLUDE
9 | }
10 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/PropertyVisitor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.kscs.util.jaxb;
26 |
27 | /**
28 | * Interface to be implemented by a property visitor
29 | */
30 | public interface PropertyVisitor {
31 | /**
32 | * Called upon visiting a top-level object
33 | * @param value The Object to be visited
34 | */
35 | void visit(final Object value);
36 |
37 | /**
38 | * Called upon visitng a collection element
39 | * @param property The property being visited
40 | * @return true if visiting shall continue, false if visiting should be finished
41 | */
42 | boolean visit(final ItemProperty, ?> property);
43 |
44 | /**
45 | * Called upon visitng a single-value property
46 | * @param property The property being visited
47 | * @return true if visiting shall continue, false if visiting should be finished
48 | */
49 | boolean visit(final SingleProperty ,?> property);
50 |
51 | /**
52 | * Called upon visiting a collection property
53 | * @param property The property being visited
54 | * @return true if visiting shall continue, false if visiting should be finished
55 | */
56 | boolean visit(final CollectionProperty, ?> property);
57 |
58 |
59 | /**
60 | * Called upon visiting a collection property, where the collection items are wrapped in a
61 | * {@link jakarta.xml.bind.JAXBElement} instance.
62 | * @param property The property being visited
63 | * @return true if visiting shall continue, false if visiting should be finished
64 | */
65 | boolean visit(final IndirectCollectionProperty ,?> property);
66 |
67 | /**
68 | * Called upon visiting a collection property, where the collection items are wrapped in a
69 | * {@link jakarta.xml.bind.JAXBElement} instance and are of a java primitive type
70 | * @param property The property being visited
71 | * @return true if visiting shall continue, false if visiting should be finished
72 | */
73 | boolean visit(final IndirectPrimitiveCollectionProperty ,?> property);
74 | }
75 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/Selector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | package com.kscs.util.jaxb;
25 |
26 | import java.util.Collections;
27 | import java.util.Map;
28 |
29 | /**
30 | * Helper class acting as base class for all selectors and
31 | * concrete implementation of leaf selectors.
32 | * @author mirko 2014-04-04
33 | */
34 | public class Selector, TParent> {
35 | public final TRoot _root;
36 | public final TParent _parent;
37 | protected final String _propertyName;
38 | protected final boolean _include;
39 |
40 | @SuppressWarnings("unchecked")
41 | public Selector(final TRoot root, final TParent parent, final String propertyName, final boolean include) {
42 | this._root = root == null ? (TRoot) this : root;
43 | this._parent = parent;
44 | this._propertyName = propertyName;
45 | this._include = include;
46 | }
47 |
48 | public Selector(final TRoot root, final TParent parent, final String propertyName) {
49 | this(root, parent, propertyName, true);
50 | }
51 |
52 | /**
53 | * This is only used by builders and other implementational details
54 | * @return A map representing the child nodes of this selector
55 | */
56 | public Map buildChildren() {
57 | return Collections.emptyMap();
58 | }
59 |
60 | /**
61 | * Builds a property tree specified by this selector
62 | * @return A property tree specified by this selector
63 | */
64 | public PropertyTree build() {
65 | return this._root.init();
66 | }
67 |
68 | /**
69 | * This is only used by builders and other implementational details
70 | * @return A property tree specified by this selector
71 | */
72 | public PropertyTree init() {
73 | return new PropertyTree(this._propertyName, buildChildren());
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/SingleProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.kscs.util.jaxb;
26 |
27 | /**
28 | * Represents the instance of a {@link SinglePropertyInfo}, i.e. represents the
29 | * property meta information along with its value, and enables to get an d set the value
30 | */
31 | public class SingleProperty extends Property {
32 |
33 | public SingleProperty(final SinglePropertyInfo info, final I owner) {
34 | super(info, owner);
35 | }
36 |
37 | @Override
38 | public SinglePropertyInfo getInfo() {
39 | return (SinglePropertyInfo)super.getInfo();
40 | }
41 |
42 | @Override
43 | public P get() {
44 | return (P)super.get();
45 | }
46 |
47 | public void set(final P value) {
48 | getInfo().set(getOwner(), value);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/SinglePropertyInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.kscs.util.jaxb;
26 |
27 | import javax.xml.namespace.QName;
28 |
29 | /**
30 | * Represents a multi-value property of a JAXB-generated java class.
31 | */
32 | public abstract class SinglePropertyInfo extends PropertyInfo {
33 | protected SinglePropertyInfo(final String propertyName, final Class declaringClass, final Class declaredType, final boolean collection, final P defaultValue, final QName schemaName, final QName schemaType, final boolean attribute) {
34 | super(propertyName, declaringClass, declaredType, collection, defaultValue, schemaName, schemaType, attribute);
35 | }
36 |
37 | @Override
38 | public abstract P get(final I instance);
39 | public abstract void set(final I instance, final P value);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/UnmodifiableListAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.kscs.util.jaxb;
26 |
27 | import java.util.Collection;
28 | import java.util.Collections;
29 | import java.util.Iterator;
30 | import java.util.List;
31 |
32 | /**
33 | * @author Mirko Klemm 2015-03-15
34 | */
35 | public class UnmodifiableListAdapter implements UnmodifiableList {
36 | private final List delegateList;
37 |
38 | public UnmodifiableListAdapter(final List delegateList) {
39 | this.delegateList = Collections.unmodifiableList(delegateList);
40 | }
41 |
42 | @Override
43 | public E get(final int index) {
44 | return this.delegateList.get(index);
45 | }
46 |
47 | @Override
48 | public int indexOf(final Object o) {
49 | return this.delegateList.indexOf(o);
50 | }
51 |
52 | @Override
53 | public int lastIndexOf(final Object o) {
54 | return this.delegateList.lastIndexOf(o);
55 | }
56 |
57 | @Override
58 | public UnmodifiableList subList(final int fromIndex, final int toIndex) {
59 | return new UnmodifiableListAdapter<>(this.delegateList.subList(fromIndex, toIndex));
60 | }
61 |
62 | @Override
63 | public int size() {
64 | return this.delegateList.size();
65 | }
66 |
67 | @Override
68 | public boolean isEmpty() {
69 | return this.delegateList.isEmpty();
70 | }
71 |
72 | @Override
73 | public boolean contains(final Object o) {
74 | return this.delegateList.contains(o);
75 | }
76 |
77 | @Override
78 | public Iterator iterator() {
79 | return this.delegateList.iterator();
80 | }
81 |
82 | @Override
83 | public Object[] toArray() {
84 | return this.delegateList.toArray();
85 | }
86 |
87 | @Override
88 | public T[] toArray(final T[] a) {
89 | return this.delegateList.toArray(a);
90 | }
91 |
92 | @Override
93 | public boolean containsAll(final Collection> c) {
94 | return this.delegateList.containsAll(c);
95 | }
96 |
97 | public List toList() {
98 | return this.delegateList;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/runtime/src/main/java/com/kscs/util/jaxb/VetoableCollectionChangeListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.kscs.util.jaxb;
26 |
27 | import java.beans.PropertyVetoException;
28 |
29 | /**
30 | * ${PROJECT_NAME}
31 | * @author klemm0
32 | * 21/02/14
33 | *
34 | */
35 | public interface VetoableCollectionChangeListener {
36 | void vetoableCollectionChange(final CollectionChangeEvent event) throws PropertyVetoException;
37 | }
38 |
--------------------------------------------------------------------------------
/src/site/site.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | org.apache.maven.skins
5 | maven-fluido-skin
6 | 2.0.0-M8
7 |
8 |
9 |
--------------------------------------------------------------------------------
/test/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | 4.0.0
7 |
8 | jaxb2-rich-contract-plugin-test
9 |
10 |
11 | net.codesup.util
12 | jaxb-rich-contract-plugin-parent
13 | 4.2.1-SNAPSHOT
14 |
15 |
16 | JAXB XJC plugin test suite
17 | jar
18 |
19 |
20 | github
21 |
22 |
23 |
24 | scm:git:https://github.com/mklemm/jaxb2-rich-contract-plugin-test.git
25 | scm:git:https://github.com/mklemm/jaxb2-rich-contract-plugin-test.git
26 | https://github.com/mklemm/jaxb2-rich-contract-plugin-test.git
27 | HEAD
28 |
29 |
30 |
31 |
32 | org.assertj
33 | assertj-core
34 | 3.25.3
35 |
36 |
37 |
38 |
39 |
40 |
41 | org.jvnet.jaxb
42 | jaxb-maven-plugin
43 | 4.0.0
44 |
45 | true
46 | false
47 |
48 | -Xclone
49 | -Xfluent-builder
50 | -Xgroup-contract
51 | -group-contract.declareSetters=n
52 | -Ximmutable
53 | -Xmodifier
54 | -Xmeta
55 | -meta.extended=y
56 | -meta.camelCase=y
57 |
58 |
59 |
60 | net.codesup.util
61 | jaxb-rich-contract-plugin
62 | ${project.version}
63 |
64 |
65 |
66 |
67 |
68 |
69 | generate
70 |
71 | generate-sources
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/test/src/main/resources/XInclude.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 | The XInclude definition is taken from the documentation at http://www.w3.org/TR/xinclude/ and is not directly
9 | provided by the W3C.
10 | The schema reflects the version 1.0.
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/test/src/main/resources/binding-config.xjb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/test/src/main/resources/math.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
20 |
21 |
22 |
23 |
24 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/test/src/main/resources/svg.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
20 |
21 |
22 |
23 |
24 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/test/src/test/java/com/kscs/jaxb2/contract/test/TouristTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * GNU General Public License
3 | *
4 | * Copyright (c) 2018 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package com.kscs.jaxb2.contract.test;
20 |
21 | import java.util.Date;
22 |
23 | import org.junit.Test;
24 |
25 | public class TouristTest {
26 | @Test
27 | public void testDateUsage() {
28 | Tourist.builder().withAge(12).withDestination("home").withDepartureDate(new Date()).build();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/test/src/test/java/com/kscs/util/jaxb/BeanAssert.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2014 Klemm Software Consulting, Mirko Klemm
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | package com.kscs.util.jaxb;
25 |
26 | import java.util.List;
27 | import java.util.logging.Logger;
28 |
29 | import org.junit.Assert;
30 |
31 | @SuppressWarnings({"nls", "boxing"})
32 | public class BeanAssert extends BeanDiff {
33 | private static final Logger LOGGER = Logger.getLogger(BeanAssert.class.getName());
34 |
35 | public BeanAssert(final String packagePrefix, final String... ignoreNames) {
36 | super(packagePrefix, 19, 10, ignoreNames);
37 | }
38 |
39 | public BeanAssert(final String packagePrefix, final int decimalPrecision, final int decimalScale, final String... ignoreNames) {
40 | super(packagePrefix, decimalPrecision, decimalScale, ignoreNames);
41 | }
42 |
43 | public void assertPropertyEquality(final Object o1, final Object o2) {
44 | final List differences = findDifferences(o1, o2);
45 | final StringBuilder diffs1 = new StringBuilder();
46 | for (final Difference diff : differences) {
47 | diffs1.append(" \t").append(diff.getPropertyName()).append(": expected=").append(diff.getExpected()).append(", actual=").append(diff.getActual()).append("\n");
48 | BeanAssert.LOGGER.fine("Assertion Failure: " + diff.getPropertyName() + ": expected=" + diff.getExpected() + ", actual="
49 | + diff.getActual());
50 | }
51 | final String diffs = diffs1.toString();
52 | Assert.assertTrue("differences:\n" + diffs, differences.isEmpty());
53 | }
54 |
55 |
56 | }
57 |
--------------------------------------------------------------------------------