Commit 80910185 authored by Daniel Bluhm's avatar Daniel Bluhm
Browse files

Documentation and refinements on Field



Whether a Field is primitive or not is now inferred from the type
passed to the Builder method type().
Signed-off-by: Daniel Bluhm's avatarDaniel Bluhm <bluhmdj@ornl.gov>
parent 66ea0337
package org.eclipse.ice.dev.annotations;
/**
* Marker interface for DataElements.
*/
public interface IDataElement {
/**
* This function checks deep equality of DataElements to see if all members are
* equal ("match") with the exception of fields with match set to false (such
* as an automatically generated UUID). This is important for checking if two
* objects were generated separately but are otherwise equal.
*
* @param o the other element to compare
* @return true if all members of the element except excluded fields match
* this element.
*/
public boolean matches(Object o);
/**
* This operation serializes the data element to a string in verified JSON.
*
* @return a JSON string describing the element
*/
public String toJSON();
/**
* This operation deserializes a valid JSON string and tries to load it into the
* object.
*
* @param jsonDataElement the contents of this data element as JSON
*/
public void fromJSON(final String jsonDataElement);
}
......@@ -29,7 +29,6 @@ public class DefaultFields {
.name("id")
.type(long.class)
.defaultValue(0L)
.primitive(true)
.build();
/**
......@@ -75,7 +74,6 @@ public class DefaultFields {
.name("required")
.type(boolean.class)
.defaultValue(false)
.primitive(true)
.build();
/**
......@@ -86,7 +84,6 @@ public class DefaultFields {
.name("secret")
.type(boolean.class)
.defaultValue(false)
.primitive(true)
.build();
/**
......
......@@ -30,16 +30,21 @@ public class Field {
/**
* Whether or not this field can be null.
*
* This value affects the kind of checks generated in IDataElement.matches().
*/
boolean nullable;
/**
* Whether or not the type of this field is a primitive type.
*
* This value affects the kind of checks generated in IDataElement.matches().
* This is inferred from the Field's type.
*/
boolean primitive;
/**
* Whether or not this field should be included in the matches method checks.
* Whether or not this field should be included in IDataElement.matches().
*/
@Builder.Default boolean match = true;
......@@ -97,6 +102,7 @@ public class Field {
*/
public FieldBuilder type(Class<?> type) {
this.type = type.getName().toString();
this.primitive = type.isPrimitive();
return this;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment