Commit 152388ba authored by Daniel Bluhm's avatar Daniel Bluhm

More PR cleanup

Signed-off-by: Daniel Bluhm's avatarDaniel Bluhm <bluhmdj@ornl.gov>
parent 97131c75
/*******************************************************************************
* Copyright (c) 2020- UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Daniel Bluhm - Initial implementation
*******************************************************************************/
package org.eclipse.ice.dev.annotations.processors;
import java.util.Arrays;
......@@ -17,13 +7,11 @@ import java.util.UUID;
import org.eclipse.ice.data.JavascriptValidator;
/**
* Aggregation of fields generated and included in <code>@DataElement</code> by
* default.
* Aggregation of fields generated and included in <code>@DataElement</code>
* by default.
*/
public class DefaultFields {
private DefaultFields() {}
/**
* The private UUID of this element.
*
......@@ -45,71 +33,106 @@ public class DefaultFields {
/**
* A unique identifier for this element.
*/
private static Field id = Field.builder().name("id").type(long.class)
.docString("A unique identifier for this element.").defaultValue(javaSource(0L)).defaultField(true).build();
private static Field id = Field.builder()
.name("id")
.type(long.class)
.docString("A unique identifier for this element.")
.defaultValue(javaSource(0L))
.defaultField(true)
.build();
/**
* A simple name for the data.
*/
private static Field name = Field.builder().name("name").type(String.class).docString("A simple name for the data.")
.defaultValue(javaSource("name")).defaultField(true).build();
private static Field name = Field.builder()
.name("name")
.type(String.class)
.docString("A simple name for the data.")
.defaultValue(javaSource("name"))
.defaultField(true)
.build();
/**
* A simple description of the data.
*/
private static Field description = Field.builder().name("description").type(String.class)
.docString("A simple description of the data").defaultValue(javaSource("description")).defaultField(true)
private static Field description = Field.builder()
.name("description")
.type(String.class)
.docString("A simple description of the data")
.defaultValue(javaSource("description"))
.defaultField(true)
.build();
/**
* A comment that annotates the data in a meaningful way.
*/
private static Field comment = Field.builder().name("comment").type(String.class)
.docString("A comment that annotates the data in a meaningful way.").defaultValue(javaSource("no comment"))
.defaultField(true).build();
private static Field comment = Field.builder()
.name("comment")
.type(String.class)
.docString("A comment that annotates the data in a meaningful way.")
.defaultValue(javaSource("no comment"))
.defaultField(true)
.build();
/**
* The context (a tag) in which the data should be considered.
*/
private static Field context = Field.builder().name("context").type(String.class)
private static Field context = Field.builder()
.name("context")
.type(String.class)
.docString("The context (a tag) in which the data should be considered.")
.defaultValue(javaSource("default")).defaultField(true).build();
.defaultValue(javaSource("default"))
.defaultField(true)
.build();
/**
* This value is true if the element should be regarded as a client as required.
*/
private static Field required = Field.builder().name("required").type(boolean.class)
private static Field required = Field.builder()
.name("required")
.type(boolean.class)
.docString("This value is true if the element should be regarded by the client as required.")
.defaultValue(javaSource(false)).defaultField(true).build();
.defaultValue(javaSource(false))
.defaultField(true)
.build();
/**
* This value is true if the element should be regarded as a secret by a client,
* such as for passwords.
*/
private static Field secret = Field.builder().name("secret").type(boolean.class).docString(
"This value is true if the element should be regarded as a secret by the client, such as for passwords.")
.defaultValue(javaSource(false)).defaultField(true).build();
private static Field secret = Field.builder()
.name("secret")
.type(boolean.class)
.docString("This value is true if the element should be regarded as a secret by the client, such as for passwords.")
.defaultValue(javaSource(false))
.defaultField(true)
.build();
/**
* The validator used to check the correctness of the data.
*/
private static Field validator = Field.builder().name("validator")
private static Field validator = Field.builder()
.name("validator")
.type(JavascriptValidator.class.getCanonicalName() + "<$interface>")
.docString("The validator used to check the correctness of the data.").nullable(true).defaultField(true)
.searchable(false).build();
.docString("The validator used to check the correctness of the data.")
.nullable(true)
.defaultField(true)
.searchable(false)
.build();
/**
* Get the statically defined default fields.
*
* @return list of Fields
*/
public static List<Field> get() {
return Arrays.asList(privateId, id, name, description, comment, context, required, secret, validator);
return Arrays.asList(
privateId, id, name, description, comment,
context, required, secret, validator
);
}
/**
* Format long as String for use as default value initializer.
*
* @param value the value to be formatted.
* @return String
*/
......@@ -119,7 +142,6 @@ public class DefaultFields {
/**
* Format String as escaped String for use as default value initializer.
*
* @param value the value to be formatted.
* @return String
*/
......@@ -129,7 +151,6 @@ public class DefaultFields {
/**
* Format boolean as String for use as default value initializer.
*
* @param value the value to be formatted.
* @return String
*/
......
......@@ -299,7 +299,11 @@ public class Field {
*/
@JsonIgnore
public FieldBuilder modifiersToString(Set<Modifier> modifiers) {
return this.modifiers(modifiers.stream().map(Object::toString).collect(Collectors.toSet()));
return this.modifiers(
modifiers.stream()
.map(Object::toString)
.collect(Collectors.toSet())
);
}
}
}
......@@ -59,7 +59,9 @@ public class Fields implements Iterable<Field> {
* @see Field#isConstant()
*/
public Iterator<Field> getConstants() {
return fields.stream().filter(Field::isConstant).iterator();
return fields.stream()
.filter(Field::isConstant)
.iterator();
}
/**
......@@ -69,7 +71,9 @@ public class Fields implements Iterable<Field> {
* @see Field#isConstant()
*/
public Iterator<Field> getMutable() {
return fields.stream().filter(field -> !field.isConstant()).iterator();
return fields.stream()
.filter(field -> !field.isConstant())
.iterator();
}
/**
......@@ -79,7 +83,9 @@ public class Fields implements Iterable<Field> {
* @see org.eclipse.ice.data.IDataElement#matches(Object)
*/
public Iterator<Field> getMatch() {
return fields.stream().filter(Field::isMatch).iterator();
return fields.stream()
.filter(Field::isMatch)
.iterator();
}
/**
......@@ -90,7 +96,9 @@ public class Fields implements Iterable<Field> {
* @see Field#isVarDifferent()
*/
public Iterator<Field> getVarNamesDiffer() {
return fields.stream().filter(Field::isVarNameDifferent).iterator();
return fields.stream()
.filter(Field::isVarNameDifferent)
.iterator();
}
/**
......
......@@ -97,6 +97,7 @@ public class PersistenceHandlerWriter
interfaceName, String implementation, String collection, @NonNull Fields
fields, @NonNull Types types
) {
super();
this.template = TEMPLATE;
this.className = className;
this.context.put(PACKAGE, packageName);
......
/**
* $name DataElement.
*/
import { DataElement } from "DataElement";
export class $name extends DataElement {
#foreach($field in $fields)
${field.VarName}?: $primitiveMap["${field.Type}"];
#end
constructor() {
super();
}
}
\ No newline at end of file
......@@ -48,9 +48,9 @@
#macro(fieldparametertype)#nonnull("", " ")#fieldtype#end
## Get field declaration
#macro(fielddecl $mutable)
#macro(fielddecl)
#@settab(1)
#if(${field.DefaultValue} && $mutable) @Builder.Default #end#join(" ", ${field.Annotations})#join(" ", ${field.Modifiers})#fieldtype() ${field.VarName}#if(${field.DefaultValue}) = #evaluate(${field.DefaultValue})#end;
#join(" ", ${field.Annotations})#join(" ", ${field.Modifiers})#fieldtype() ${field.VarName}#if(${field.DefaultValue}) = #evaluate(${field.DefaultValue})#end;
#end
#end
......
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