Skip to content

Commit

Permalink
Reformatted code.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed Aug 21, 2022
1 parent 8291665 commit 89f4b4f
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static void buildValueConstraints(
@NonNull IValuedDefinition definition) {
if (!definition.getConstraints().isEmpty()) {
AnnotationSpec.Builder valueConstraintsAnnotation = AnnotationSpec.builder(ValueConstraints.class);

applyAllowedValuesConstraints(valueConstraintsAnnotation, definition.getAllowedValuesConstraints());
applyIndexHasKeyConstraints(valueConstraintsAnnotation, definition.getIndexHasKeyConstraints());
applyMatchesConstraints(valueConstraintsAnnotation, definition.getMatchesConstraints());
Expand All @@ -139,7 +139,7 @@ public static void buildValueConstraints(
List<? extends IIndexHasKeyConstraint> indexHasKey = definition.getIndexHasKeyConstraints();
List<? extends IMatchesConstraint> matches = definition.getMatchesConstraints();
List<? extends IExpectConstraint> expects = definition.getExpectConstraints();

if (!allowedValues.isEmpty() || !indexHasKey.isEmpty() || !matches.isEmpty() || !expects.isEmpty()) {
AnnotationSpec.Builder annotation = AnnotationSpec.builder(ValueConstraints.class);

Expand All @@ -155,11 +155,11 @@ public static void buildValueConstraints(
public static void buildAssemblyConstraints(
@NonNull TypeSpec.Builder builder,
@NonNull IAssemblyDefinition definition) {

List<? extends IIndexConstraint> index = definition.getIndexConstraints();
List<? extends IUniqueConstraint> unique = definition.getUniqueConstraints();
List<? extends ICardinalityConstraint> cardinality = definition.getHasCardinalityConstraints();

if (!index.isEmpty() || !unique.isEmpty() || !cardinality.isEmpty()) {
AnnotationSpec.Builder annotation = AnnotationSpec.builder(AssemblyConstraints.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void processModel(IModelContainer model) {
// create model instances for the model
for (IModelInstance instance : model.getModelInstances()) {
assert instance != null;

if (instance instanceof IChoiceInstance) {
processModel((IChoiceInstance) instance);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected Set<IModelDefinition> buildField(FieldSpec.Builder builder) {
if (defaultValue != null) {
fieldValue.addMember("defaultValue", "$S", valueDataType.asString(defaultValue));
}

builder.addAnnotation(fieldValue.build());
return CollectionUtil.emptySet();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected Set<IModelDefinition> buildField(@NonNull FieldSpec.Builder builder) {
}

builder.addAnnotation(annotation.build());

AnnotationUtils.buildValueConstraints(builder, definition);

IModelDefinition parent = instance.getContainingDefinition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,8 @@ public Set<IModelDefinition> buildField(FieldSpec.Builder builder) { // NOPMD -
IFieldDefinition fieldDefinition = (IFieldDefinition) definition;
IDataTypeAdapter<?> valueDataType = fieldDefinition.getJavaTypeAdapter();


Object defaultValue = fieldDefinition.getDefaultValue();

if (!MetaschemaDataTypeProvider.DEFAULT_DATA_TYPE.equals(valueDataType) || defaultValue != null) {
AnnotationSpec.Builder boundFieldValueAnnotation = AnnotationSpec.builder(BoundFieldValue.class);

Expand All @@ -238,7 +237,7 @@ public Set<IModelDefinition> buildField(FieldSpec.Builder builder) { // NOPMD -

if (maxOccurs == -1 || maxOccurs > 1) {
AnnotationSpec.Builder groupAsAnnoation = AnnotationSpec.builder(GroupAs.class);

groupAsAnnoation.addMember("name", "$S",
ObjectUtils.requireNonNull(modelInstance.getGroupAsName(), "The grouping name must be non-null"));

Expand All @@ -262,10 +261,10 @@ public Set<IModelDefinition> buildField(FieldSpec.Builder builder) { // NOPMD -
groupAsAnnoation.addMember("inXml", "$T.$L",
XmlGroupAsBehavior.class, xmlGroupAsBehavior.toString());
}

builder.addAnnotation(groupAsAnnoation.build());
}

return retval.isEmpty() ? CollectionUtil.emptySet() : CollectionUtil.unmodifiableSet(retval);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public interface IValuedDefinition extends IDefinition {
*/
@NonNull
IDataTypeAdapter<?> getJavaTypeAdapter();

@Nullable
Object getDefaultValue();
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,31 @@ private Builder(@NonNull List<? extends IConstraint> constraints, @NonNull INode
this.constraints = constraints;
this.node = node;
}

@NonNull
public Builder message(@NonNull CharSequence message) {
this.message = message;
return this;
}

@NonNull
public Builder target(@NonNull INodeItem target) {
this.targets = Collections.singletonList(target);
return this;
}

@NonNull
public Builder targets(@NonNull List<? extends INodeItem> targets) {
this.targets = CollectionUtil.unmodifiableList(targets);
return this;
}

@NonNull
public Builder cause(@NonNull Throwable cause) {
this.cause = cause;
return this;
}

@NonNull
public Builder severity(@NonNull Level severity) {
this.severity = severity;
Expand All @@ -163,18 +163,18 @@ public ConstraintValidationFinding build() {
if (message == null) {
throw new IllegalStateException("Missing message");
}

Level severity = this.severity == null ? constraints.stream()
.map(IConstraint::getLevel)
.max(Comparator.comparing(Level::ordinal))
.get() : this.severity;

List<? extends INodeItem> targets = this.targets == null ? CollectionUtil.emptyList() : this.targets;

assert message != null;
assert targets != null;
assert severity != null;

return new ConstraintValidationFinding(
constraints,
node,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public interface IDataTypeAdapter<TYPE> {

/**
* Get the most preferred name for this data type.
*
* @return the name
*/
@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

import edu.umd.cs.findbugs.annotations.NonNull;

public abstract class AbstractAssemblyInstanceNodeItem<F extends IFlagNodeItem, M extends IModelNodeItem,
P extends INodeItem, L extends AbstractModelNodeContext.Model<F, M>>
public abstract class AbstractAssemblyInstanceNodeItem<F extends IFlagNodeItem, M extends IModelNodeItem, P extends INodeItem, L extends AbstractModelNodeContext.Model<
F, M>>
extends AbstractModelNodeContext<F, M, L>
implements IAssemblyNodeItem {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
* @param <P>
* the parent node item type
*/
abstract class AbstractFieldInstanceNodeItem<F extends IFlagNodeItem, P extends IAssemblyNodeItem,
L extends AbstractNodeContext.Flags<F>>
abstract class AbstractFieldInstanceNodeItem<F extends IFlagNodeItem, P extends IAssemblyNodeItem, L extends AbstractNodeContext.Flags<
F>>
extends AbstractNodeContext<F, L>
implements IFieldNodeItem {
@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

import edu.umd.cs.findbugs.annotations.NonNull;

public abstract class AbstractModelNodeContext<F extends IFlagNodeItem, M extends IModelNodeItem,
L extends AbstractModelNodeContext.Model<F, M>>
public abstract class AbstractModelNodeContext<F extends IFlagNodeItem, M extends IModelNodeItem, L extends AbstractModelNodeContext.Model<
F, M>>
extends AbstractNodeContext<F, L> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,11 @@ public static CharSequence toString(XMLEvent xmlEvent) {
@SuppressWarnings("null")
@NonNull
public static CharSequence toString(@Nullable Location location) {
return location == null ? "unknown" : new StringBuilder()
.append(location.getLineNumber())
.append(':')
.append(location.getColumnNumber());
return location == null ? "unknown"
: new StringBuilder()
.append(location.getLineNumber())
.append(':')
.append(location.getColumnNumber());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class IBase64BinaryItemTest {
private static final long MIN_LONG = -9_223_372_036_854_775_808L;
private static final long MAX_LONG = 9_223_372_036_854_775_807L;
private static final String BASE_64 = "gAAAAAAAAAB//////////w==";


@Test
void testValueOf() {
Expand Down

0 comments on commit 89f4b4f

Please sign in to comment.