protected void validateElementType(Object o) {
   if (o != null) {
     ModelType<?> obType = ModelType.of(o.getClass());
     if (!obType.equals(elementType)) {
       throw new IllegalArgumentException(
           String.format(
               "Cannot add an element of type %s to a collection of %s", obType, elementType));
     }
   }
 }
    @Override
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }

      ListViewFactory<?> that = (ListViewFactory<?>) o;
      return elementType.equals(that.elementType);
    }
Example #3
0
 @Nullable
 public ModelType<?> getUpperBound() {
   WildcardWrapper wildcardType = getWildcardType();
   if (wildcardType == null) {
     return null;
   } else {
     ModelType<?> upperBound = Simple.typed(wildcardType.getUpperBound());
     if (upperBound.equals(UNTYPED)) {
       return null;
     }
     return upperBound;
   }
 }