Commit 3c2639b9 authored by Daniel Bluhm's avatar Daniel Bluhm

Fix whitespace, license, docs

Signed-off-by: Daniel Bluhm's avatarDaniel Bluhm <bluhmdj@ornl.gov>
parent 35671093
/*******************************************************************************
* 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.lang.annotation.Annotation;
......@@ -15,7 +26,7 @@ import javax.lang.model.element.AnnotationValue;
/**
* Helper for accessing and working with Annotated Classes.
*
*
* @author Daniel Bluhm
*/
public class AnnotatedElement {
......@@ -36,7 +47,7 @@ public class AnnotatedElement {
/**
* Construct an AnnotatedElement from an Element.
*
*
* @param element The annotated element
* @param elementUtils Elements helper from processing environment
*/
......@@ -47,7 +58,7 @@ public class AnnotatedElement {
/**
* Determine if an annotation of a given type decorates this element.
*
*
* @param cls class of annotation to check
* @return whether annotation is present or not
*/
......@@ -57,7 +68,7 @@ public class AnnotatedElement {
/**
* Get the AnnotationMirror of a given type if present on the element.
*
*
* @param <T> Type of annotation to retrieve
* @param cls class of annotation to retrieve
* @return AnnotationMirror or null if not found
......@@ -76,7 +87,7 @@ public class AnnotatedElement {
* This is useful when dealing with a complicated Annotation potentially
* containing a value that is a Class object. Otherwise, it is recommended to
* directly retrieve the value from an Annotation instance.
*
*
* @param annotationClass the class of the annotation from which values will be
* retrieved.
* @return Map of String to unwrapped AnnotationValue (Object)
......@@ -95,7 +106,7 @@ public class AnnotatedElement {
* This is useful when dealing with a complicated Annotation potentially
* containing a value that is a Class object. Otherwise, it is recommended to
* directly retrieve the value from an Annotation instance.
*
*
* @param annotationClass the class of the annotation from which values will be
* retrieved.
* @return list of AnnotationValue
......@@ -109,7 +120,7 @@ public class AnnotatedElement {
/**
* Find and return annotation of a given on this element.
*
*
* @param annotationClass Class of annotation mirror to retrieve
* @return {@link Optional} of annotation mirror
*/
......
/*******************************************************************************
* 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.Optional;
......
......@@ -5,6 +5,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Michael Walsh - Initial implementation
* Daniel Bluhm - Modifications
*******************************************************************************/
package org.eclipse.ice.dev.annotations.processors;
......@@ -29,13 +30,14 @@ import lombok.Builder;
* from Spec classes with the class level annotation of {@link DataElement}
*
* @author Michael Walsh
* @author Daniel Bluhm
*/
public class DataElementAnnotationExtractor
public class DataElementExtractor
implements AnnotationExtractor<DataElementMetadata> {
/**
* Logger.
*/
private static final Logger logger = LoggerFactory.getLogger(DataElementAnnotationExtractor.class);
private static final Logger logger = LoggerFactory.getLogger(DataElementExtractor.class);
/**
* Element utilities from annotation processing environment.
......@@ -54,7 +56,7 @@ public class DataElementAnnotationExtractor
* DataField.
*/
@Builder
public DataElementAnnotationExtractor(
public DataElementExtractor(
Elements elementUtils,
DataFieldExtractor dataFieldExtractor
) {
......
/*******************************************************************************
* 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 lombok.Builder;
import lombok.Data;
import lombok.experimental.SuperBuilder;
/**
* POJO representing metadata extracted from DataElement and associated
......@@ -10,7 +21,7 @@ import lombok.experimental.SuperBuilder;
* @author Daniel Bluhm
*/
@Data
@SuperBuilder
@Builder
public class DataElementMetadata {
/**
* Base name of classes to be generated.
......
......@@ -42,8 +42,8 @@ import com.google.auto.service.AutoService;
* This will generate an implementation for an interface annotated with
* DataElement, populating the implementation with metadata and fields specified
* with the DataField annotation.
*
* @author Daniel Bluhm
*
* @author Daniel Bluhm
* @author Michael Walsh
*
*/
......@@ -58,7 +58,7 @@ import com.google.auto.service.AutoService;
public class DataElementProcessor extends AbstractProcessor {
/**
* Return stack trace as string.
*
*
* @param e subject exception
* @return stack trace as string
*/
......@@ -88,14 +88,14 @@ public class DataElementProcessor extends AbstractProcessor {
/**
* For the extraction of key data from Spec classes used in class generation
*/
protected DataElementAnnotationExtractor extractor;
protected DataElementExtractor extractor;
@Override
public synchronized void init(final ProcessingEnvironment env) {
this.messager = env.getMessager();
this.elementUtils = env.getElementUtils();
this.mapper = new ObjectMapper();
this.extractor = DataElementAnnotationExtractor.builder()
this.extractor = DataElementExtractor.builder()
.elementUtils(elementUtils)
.dataFieldExtractor(new DataFieldExtractor(elementUtils))
.build();
......
......@@ -23,10 +23,12 @@ import lombok.AllArgsConstructor;
* Uses metadata extracted from spec classes annotated with @DataElement to
* generate the interface, implementation, and persistence handler.
*
* @author Michael Walsh
* @author Daniel Bluhm
*/
@AllArgsConstructor
public class DataElementWriterGenerator implements WriterGenerator {
/**
* Logger.
*/
......
/*******************************************************************************
* 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.List;
......@@ -15,6 +26,10 @@ import org.eclipse.ice.dev.annotations.DataField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Extractor for DataField annotated elements.
* @author Daniel Bluhm
*/
public class DataFieldExtractor implements AnnotationExtractor<Field> {
/**
......
......@@ -21,13 +21,8 @@ import org.eclipse.ice.data.JavascriptValidator;
* default.
*/
public class DefaultFields {
/*
* Explicit private constructor to hide implicit public constructor, otherwise this would be a code smell
*/
private DefaultFields() {
}
private DefaultFields() {}
/**
* The private UUID of this element.
......@@ -105,7 +100,7 @@ public class DefaultFields {
/**
* Get the statically defined default fields.
*
*
* @return list of Fields
*/
public static List<Field> get() {
......@@ -114,7 +109,7 @@ public class DefaultFields {
/**
* Format long as String for use as default value initializer.
*
*
* @param value the value to be formatted.
* @return String
*/
......@@ -124,7 +119,7 @@ public class DefaultFields {
/**
* Format String as escaped String for use as default value initializer.
*
*
* @param value the value to be formatted.
* @return String
*/
......@@ -134,7 +129,7 @@ public class DefaultFields {
/**
* Format boolean as String for use as default value initializer.
*
*
* @param value the value to be formatted.
* @return String
*/
......
/*******************************************************************************
* 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.Collection;
......@@ -133,7 +144,7 @@ public class Field {
* Get the name of the variable representing this field.
*
* If no variable name has been specifically set, var == name.
*
*
* @return the name of the variable
*/
@JsonIgnore
......@@ -146,7 +157,7 @@ public class Field {
/**
* Get whether this field has a variable name that differs from the field name.
*
*
* @return whether the variable name differs from the field name
*/
@JsonIgnore
......@@ -156,7 +167,7 @@ public class Field {
/**
* Return this Fields name ready for use in a method name.
*
*
* @return capitalized name
*/
@JsonIgnore
......@@ -170,7 +181,7 @@ public class Field {
* Due to the use of the Lombok {@code @Data} annotatation on DataElements, by
* Lombok convention, Getters for fields of type {@code boolean} use "is"
* instead of "get".
*
*
* @return getter method name
*/
@JsonIgnore
......@@ -186,7 +197,7 @@ public class Field {
/**
* Return if this field has a final modifier and is therefore a constant value.
*
*
* @return field is constant
*/
@JsonIgnore
......@@ -230,7 +241,7 @@ public class Field {
public static class FieldBuilder implements FieldBuilderMeta {
/**
* Format type as String.
*
*
* @param type the type to be formatted.
* @return this
*/
......@@ -243,7 +254,7 @@ public class Field {
/**
* Format type as a String from a TypeMirror.
*
*
* @param type typemirror representing the type of this Field
* @return this
*/
......@@ -258,7 +269,7 @@ public class Field {
/**
* Set type to string. Attempts to determine the type to mark whether it is
* primitive or not.
*
*
* @param type String representation of type of this Field
* @return this
*/
......@@ -282,7 +293,7 @@ public class Field {
/**
* Format Modifiers as string.
*
*
* @param modifiers set of {@link Modifier}s
* @return this
*/
......
/*******************************************************************************
* 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.ArrayList;
......@@ -8,7 +19,7 @@ import java.util.stream.Collectors;
/**
* A collection of Field objects to be used especially in template rendering.
*
*
* @author Daniel Bluhm
*/
public class Fields implements Iterable<Field> {
......@@ -24,7 +35,7 @@ public class Fields implements Iterable<Field> {
/**
* Create Fields from existing collection of Field objects.
*
*
* @param fields initial fields
*/
public Fields(Collection<Field> fields) {
......@@ -34,7 +45,7 @@ public class Fields implements Iterable<Field> {
/**
* Add fields to the collection.
*
*
* @param fields to add
*/
public void collect(Collection<Field> fields) {
......@@ -91,7 +102,7 @@ public class Fields implements Iterable<Field> {
.filter(field -> !field.isDefaultField())
.collect(Collectors.toList());
}
/**
* Return Fields that are not marked as default.
* @return Fields new instance with default fields filtered out.
......
/*******************************************************************************
* 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.io.Writer;
......
/*******************************************************************************
* 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.io.IOException;
......
......@@ -7,7 +7,7 @@
*
* Contributors:
* Daniel Bluhm - Initial implementation
* Michael Walsh
* Michael Walsh - Modifications
*******************************************************************************/
package org.eclipse.ice.dev.annotations.processors;
......
......@@ -7,7 +7,7 @@
*
* Contributors:
* Daniel Bluhm - Initial implementation
* Michael Walsh
* Michael Walsh - Modifications
*******************************************************************************/
package org.eclipse.ice.dev.annotations.processors;
......
/*******************************************************************************
* 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;
/**
......
/*******************************************************************************
* 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 javax.lang.model.element.Element;
......@@ -7,7 +18,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Extractor for persistence metadata.
* Extractor for persistence metadata on Persisted annotated elements.
* @author Daniel Bluhm
*/
public class PersistenceExtractor implements AnnotationExtractor<PersistenceMetadata> {
......
......@@ -7,7 +7,7 @@
*
* Contributors:
* Daniel Bluhm - Initial implementation
* Michael Walsh
* Michael Walsh - Modifications
*******************************************************************************/
package org.eclipse.ice.dev.annotations.processors;
......
/*******************************************************************************
* 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 lombok.Builder;
......
/*******************************************************************************
* 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.List;
import lombok.AllArgsConstructor;
/**
* WriterGenerator for Persistence related generated file writers.
* @author Daniel Bluhm
*/
@AllArgsConstructor
public class PersistenceWriterGenerator implements WriterGenerator {