public void addCustomAnnotation(final AnnotationBuilder<? extends Annotation> annotation) { VerifyArgument.notNull(annotation, "annotation"); final AnnotationBuilder[] newAnnotations = new AnnotationBuilder[this._annotations.size() + 1]; _annotations.toArray(newAnnotations); newAnnotations[this._annotations.size()] = annotation; _annotations = new ReadOnlyList<AnnotationBuilder<? extends Annotation>>(newAnnotations); }
private static List<Object> resolveCore( final AstNode location, final String name, final NameResolveMode mode) { final Set<Object> results = FindDeclarationVisitor.resolveName(location, name, mode); if (results.isEmpty()) { return ReadOnlyList.emptyList(); } return new ReadOnlyList<>(Object.class, results); }
@Override public final T previous() { if (!hasPrevious()) { throw new IllegalStateException(); } return _list.get(--_position); }
@NotNull @Override public ReadOnlyList<T> subList(final int fromIndex, final int toIndex) { subListRangeCheck(fromIndex, toIndex, size()); return new ReadOnlyList<>(this, _offset + fromIndex, _offset + toIndex); }
ParameterBuilder( final MethodBuilder declaringMethod, final int position, final String name, final Type<?> parameterType) { _declaringMethod = VerifyArgument.notNull(declaringMethod, "declaringMethod"); _position = position; _name = name != null ? name : "p" + position; _parameterType = VerifyArgument.notNull(parameterType, "parameterType"); _annotations = ReadOnlyList.emptyList(); }
protected ReadOnlyList<T> newInstance() { return new ReadOnlyList<>(_elements, _offset, _length); }
private void writeAnnotation(final AnnotationBuilder<? extends Annotation> a) { _dataBuffer.putShort(_typeBuilder.getUtf8StringToken(a.getAnnotationType().getSignature())); _dataBuffer.putShort(a.getValues().size()); final MethodList attributes = a.getAttributes(); final ReadOnlyList<Object> values = a.getValues(); for (int i = 0, n = attributes.size(); i < n; i++) { final MethodInfo attribute = attributes.get(i); _dataBuffer.putShort(_typeBuilder.getUtf8StringToken(attribute.getName())); writeAttributeType(values.get(i)); } }
@Override public final boolean isEmpty() { return size() == 0; }
@NotNull @Override @SuppressWarnings("unchecked") public final Iterator<T> iterator() { if (isEmpty()) { return (Iterator<T>) EMPTY_ITERATOR; } return new ReadOnlyCollectionIterator(this); }
private ReadOnlyList(final ReadOnlyList<T> baseList, final int offset, final int length) { VerifyArgument.notNull(baseList, "baseList"); final T[] elements = baseList._elements; subListRangeCheck(offset, offset + length, elements.length); _elements = elements; _offset = offset; _length = length; }
@Override public final boolean containsAll(@NotNull final Collection<?> c) { for (final Object o : c) { if (!contains(o)) { return false; } } return true; }
@Override public final boolean contains(final Object o) { return indexOf(o) != -1; }
@Override public String toString() { final Iterator<T> it = iterator(); if (!it.hasNext()) { return "[]"; } final StringBuilder sb = new StringBuilder(); sb.append('['); for (; ; ) { final T e = it.next(); sb.append(e == this ? "(this Collection)" : e); if (!it.hasNext()) { return sb.append(']').toString(); } sb.append(',').append(' '); } }
@NotNull @Override public ReadOnlyList<T> subList(final int fromIndex, final int toIndex) { subListRangeCheck(fromIndex, toIndex, size()); return new ReadOnlyList<>(this, _offset + fromIndex, _offset + toIndex); }
ParameterBuilder( final MethodBuilder declaringMethod, final int position, final String name, final Type<?> parameterType) { _declaringMethod = VerifyArgument.notNull(declaringMethod, "declaringMethod"); _position = position; _name = name != null ? name : "p" + position; _parameterType = VerifyArgument.notNull(parameterType, "parameterType"); _annotations = ReadOnlyList.emptyList(); }
protected ReadOnlyList<T> newInstance() { return new ReadOnlyList<>(_elements, _offset, _length); }
private void writeAnnotation(final AnnotationBuilder<? extends Annotation> a) { _dataBuffer.putShort(_typeBuilder.getUtf8StringToken(a.getAnnotationType().getSignature())); _dataBuffer.putShort(a.getValues().size()); final MethodList attributes = a.getAttributes(); final ReadOnlyList<Object> values = a.getValues(); for (int i = 0, n = attributes.size(); i < n; i++) { final MethodInfo attribute = attributes.get(i); _dataBuffer.putShort(_typeBuilder.getUtf8StringToken(attribute.getName())); writeAttributeType(values.get(i)); } }
@Override public final boolean isEmpty() { return size() == 0; }
private int writeJavaAnnotations(final ReadOnlyList<AnnotationBuilder<? extends Annotation>> annotations) { if (annotations == null || annotations.isEmpty()) { return 0;
private ReadOnlyList(final ReadOnlyList<T> baseList, final int offset, final int length) { VerifyArgument.notNull(baseList, "baseList"); final T[] elements = baseList._elements; subListRangeCheck(offset, offset + length, elements.length); _elements = elements; _offset = offset; _length = length; }