Skip to content

Commit ce6e3a7

Browse files
committed
Improve InterfaceArchetype annotations
Use a plain class-level @NonNullByDefault, as the only place we have @nullable is a method argument. JIRA: YANGTOOLS-1884 Change-Id: I46a36607fbaeb787bc9b5ad50604368b4211094e Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
1 parent 4085e79 commit ce6e3a7

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

binding/binding-model/src/main/java/org/opendaylight/yangtools/binding/model/api/InterfaceArchetype.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import com.google.common.annotations.Beta;
1111
import java.util.List;
12-
import org.eclipse.jdt.annotation.NonNull;
1312
import org.eclipse.jdt.annotation.NonNullByDefault;
1413
import org.eclipse.jdt.annotation.Nullable;
1514
import org.opendaylight.yangtools.concepts.Mutable;
@@ -21,6 +20,7 @@
2120
*/
2221
// TODO: a better name perhaps?
2322
@Beta
23+
@NonNullByDefault
2424
public sealed interface InterfaceArchetype extends Archetype permits DataRootArchetype, LegacyArchetype {
2525
/**
2626
* Base interface for builders resulting in an {@link InterfaceArchetype}.
@@ -32,7 +32,6 @@ sealed interface Builder extends Mutable permits InterfaceArchetypeBuilder {
3232
/**
3333
* {@return a {@link TypeRef} to the type this builder produces}
3434
*/
35-
@NonNullByDefault
3635
TypeRef typeRef();
3736

3837
/**
@@ -41,7 +40,7 @@ sealed interface Builder extends Mutable permits InterfaceArchetypeBuilder {
4140
* @param annotation the {@link AttachedAnnotation.ToType}, if {@code null} this method does nothing
4241
* @return this instance
4342
*/
44-
@NonNull Builder addAnnotation(AttachedAnnotation.@Nullable ToType annotation);
43+
Builder addAnnotation(AttachedAnnotation.@Nullable ToType annotation);
4544

4645
/**
4746
* Adds a new enclosed {@link Archetype} into definition of Generated Type.
@@ -57,7 +56,6 @@ sealed interface Builder extends Mutable permits InterfaceArchetypeBuilder {
5756
*
5857
* @param genType the enclosed {@link Archetype}
5958
*/
60-
@NonNullByDefault
6159
Builder addEnclosedType(Archetype genType);
6260

6361
/**
@@ -66,7 +64,6 @@ sealed interface Builder extends Mutable permits InterfaceArchetypeBuilder {
6664
* @param genType Type to implement
6765
* @return <code>true</code> if the addition of type is successful.
6866
*/
69-
@NonNullByDefault
7067
Builder addImplementsType(Type genType);
7168

7269
/**
@@ -80,7 +77,6 @@ sealed interface Builder extends Mutable permits InterfaceArchetypeBuilder {
8077
* @param value Assigned Value
8178
* @return <code>new</code> Constant instance.
8279
*/
83-
@NonNullByDefault
8480
Constant addConstant(Type type, String name, Object value);
8581

8682
/**
@@ -92,20 +88,18 @@ sealed interface Builder extends Mutable permits InterfaceArchetypeBuilder {
9288
* @param name Name of Method
9389
* @return <code>new</code> instance of Method Signature Builder.
9490
*/
95-
@NonNullByDefault
9691
MethodSignature.Builder addMethod(String name);
9792

9893
/**
9994
* {@return a new immutable {@link InterfaceArchetype} instance}
10095
*/
101-
@NonNull InterfaceArchetype build();
96+
InterfaceArchetype build();
10297
}
10398

10499
/**
105100
* {@return the list of annotations attached to interface declaration}
106101
*/
107102
// FIXME: all type annotations should be implied by specialization and this method should not exist
108-
@NonNullByDefault
109103
List<AttachedAnnotation.ToType> annotations();
110104

111105
/**
@@ -115,14 +109,12 @@ sealed interface Builder extends Mutable permits InterfaceArchetypeBuilder {
115109
// - only allow GroupingArchetypes here
116110
// - have CaseArchetype have a dedicated pointer to its inherited ChoiceArchetype
117111
// everything else should be implied by the archetype itself
118-
@NonNullByDefault
119112
List<Type> getImplements();
120113

121114
/**
122115
* {@return the list of constants the interface defines}
123116
*/
124117
// FIXME: all constants should be implied by a particular archetype and this method should not exist
125-
@NonNullByDefault
126118
List<Constant> getConstantDefinitions();
127119

128120
/**
@@ -131,6 +123,8 @@ sealed interface Builder extends Mutable permits InterfaceArchetypeBuilder {
131123
// FIXME: yes, these result in methods being generated, but they are somewhat subtle, as they also imply constants
132124
// for builders, etc. Most notably, KeyArchetype is presenting a subset of these defined in its corresponding
133125
// LegacyArchetype (or EntryObjectArchetype once that is created)
134-
@NonNullByDefault
135126
List<MethodSignature> getMethodDefinitions();
127+
128+
@Override
129+
String toString();
136130
}

0 commit comments

Comments
 (0)