Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Fix whitespace, license, docs
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <bluhmdj@ornl.gov>
  • Loading branch information
dbluhm committed Oct 12, 2020
1 parent 3567109 commit 3c2639b
Show file tree
Hide file tree
Showing 23 changed files with 221 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*******************************************************************************
* 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;
Expand All @@ -15,7 +26,7 @@

/**
* Helper for accessing and working with Annotated Classes.
*
*
* @author Daniel Bluhm
*/
public class AnnotatedElement {
Expand All @@ -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
*/
Expand All @@ -47,7 +58,7 @@ public AnnotatedElement(Element element, Elements elementUtils) {

/**
* 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
*/
Expand All @@ -57,7 +68,7 @@ public boolean hasAnnotation(Class<? extends Annotation> cls) {

/**
* 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
Expand All @@ -76,7 +87,7 @@ public <T extends Annotation> Optional<T> getAnnotation(Class<T> cls) {
* 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)
Expand All @@ -95,7 +106,7 @@ public Map<String, Object> getAnnotationValueMap(Class<?> annotationClass) {
* 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
Expand All @@ -109,7 +120,7 @@ public List<AnnotationValue> getAnnotationValues(Class<?> annotationClass) {

/**
* Find and return annotation of a given on this element.
*
*
* @param annotationClass Class of annotation mirror to retrieve
* @return {@link Optional} of annotation mirror
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*******************************************************************************
* 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -29,13 +30,14 @@
* 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.
Expand All @@ -54,7 +56,7 @@ public class DataElementAnnotationExtractor
* DataField.
*/
@Builder
public DataElementAnnotationExtractor(
public DataElementExtractor(
Elements elementUtils,
DataFieldExtractor dataFieldExtractor
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
/*******************************************************************************
* 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
Expand All @@ -10,7 +21,7 @@
* @author Daniel Bluhm
*/
@Data
@SuperBuilder
@Builder
public class DataElementMetadata {
/**
* Base name of classes to be generated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
* 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
*
*/
Expand All @@ -58,7 +58,7 @@
public class DataElementProcessor extends AbstractProcessor {
/**
* Return stack trace as string.
*
*
* @param e subject exception
* @return stack trace as string
*/
Expand Down Expand Up @@ -88,14 +88,14 @@ private static String stackTraceToString(final Throwable e) {
/**
* 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
* 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.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*******************************************************************************
* 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;
Expand All @@ -15,6 +26,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Extractor for DataField annotated elements.
* @author Daniel Bluhm
*/
public class DataFieldExtractor implements AnnotationExtractor<Field> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@
* 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.
Expand Down Expand Up @@ -105,7 +100,7 @@ private DefaultFields() {

/**
* Get the statically defined default fields.
*
*
* @return list of Fields
*/
public static List<Field> get() {
Expand All @@ -114,7 +109,7 @@ public static List<Field> get() {

/**
* Format long as String for use as default value initializer.
*
*
* @param value the value to be formatted.
* @return String
*/
Expand All @@ -124,7 +119,7 @@ private static String javaSource(long value) {

/**
* Format String as escaped String for use as default value initializer.
*
*
* @param value the value to be formatted.
* @return String
*/
Expand All @@ -134,7 +129,7 @@ private static String javaSource(String value) {

/**
* Format boolean as String for use as default value initializer.
*
*
* @param value the value to be formatted.
* @return String
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*******************************************************************************
* 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;
Expand Down Expand Up @@ -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
Expand All @@ -146,7 +157,7 @@ public String getVarName() {

/**
* 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
Expand All @@ -156,7 +167,7 @@ public boolean isVarNameDifferent() {

/**
* Return this Fields name ready for use in a method name.
*
*
* @return capitalized name
*/
@JsonIgnore
Expand All @@ -170,7 +181,7 @@ public String getNameForMethod() {
* 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
Expand All @@ -186,7 +197,7 @@ public String getGetterName() {

/**
* Return if this field has a final modifier and is therefore a constant value.
*
*
* @return field is constant
*/
@JsonIgnore
Expand Down Expand Up @@ -230,7 +241,7 @@ private interface FieldBuilderMeta {
public static class FieldBuilder implements FieldBuilderMeta {
/**
* Format type as String.
*
*
* @param type the type to be formatted.
* @return this
*/
Expand All @@ -243,7 +254,7 @@ public FieldBuilder type(Class<?> type) {

/**
* Format type as a String from a TypeMirror.
*
*
* @param type typemirror representing the type of this Field
* @return this
*/
Expand All @@ -258,7 +269,7 @@ public FieldBuilder type(TypeMirror type) {
/**
* 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
*/
Expand All @@ -282,7 +293,7 @@ public FieldBuilder type(String type) {

/**
* Format Modifiers as string.
*
*
* @param modifiers set of {@link Modifier}s
* @return this
*/
Expand Down

0 comments on commit 3c2639b

Please sign in to comment.