}
public static <S,G,P> Class<P> findFirstGenericArgument(final Class<S> scannedClass, final Class<G> genericType) {
- return withClassLoader(scannedClass.getClassLoader(), ClassLoaderUtils.<S,G,P>findFirstGenericArgumentTask(scannedClass, genericType));
+ return withClassLoader(scannedClass.getClassLoader(), ClassLoaderUtils.findFirstGenericArgumentTask(scannedClass, genericType));
}
private static <S,G,P> Supplier<Class<P>> findFirstGenericArgumentTask(final Class<S> scannedClass, final Class<G> genericType) {
throw new UnsupportedOperationException("Helper class");
}
- public static final Set<Class<?>> KNOWN_IMMUTABLES = ImmutableSet.<Class<?>>of(
+ public static final Set<Class<?>> KNOWN_IMMUTABLES = ImmutableSet.of(
Integer.class, Short.class, BigDecimal.class, BigInteger.class, Byte.class, Character.class, Double.class,
Float.class, String.class, Boolean.class, Void.class);
if (listener == null) {
throw new IllegalArgumentException("Listener should not be null.");
}
- final ListenerRegistrationImpl<T> ret = new ListenerRegistrationImpl<T>(listener);
+ final ListenerRegistrationImpl<T> ret = new ListenerRegistrationImpl<>(listener);
listeners.put(ret,ret);
return ret;
}
public <L extends T> ListenerRegistration<L> registerWithType(final L listener) {
- final ListenerRegistrationImpl<L> ret = new ListenerRegistrationImpl<L>(listener);
+ final ListenerRegistrationImpl<L> ret = new ListenerRegistrationImpl<>(listener);
listeners.put(ret,ret);
return ret;
}
public abstract class MutableOffsetMap<K, V> extends AbstractMap<K, V> implements Cloneable, ModifiableMapPhase<K, V> {
static final class Ordered<K, V> extends MutableOffsetMap<K, V> {
Ordered() {
- super(new LinkedHashMap<K, V>());
+ super(new LinkedHashMap<>());
}
Ordered(final Map<K, V> source) {
- super(OffsetMapCache.orderedOffsets(source.keySet()), source, new LinkedHashMap<K, V>());
+ super(OffsetMapCache.orderedOffsets(source.keySet()), source, new LinkedHashMap<>());
}
Ordered(final Map<K, Integer> offsets, final V[] objects) {
- super(offsets, objects, new LinkedHashMap<K, V>());
+ super(offsets, objects, new LinkedHashMap<>());
}
@Override
static final class Unordered<K, V> extends MutableOffsetMap<K, V> {
Unordered() {
- super(new HashMap<K, V>());
+ super(new HashMap<>());
}
Unordered(final Map<K, V> source) {
- super(OffsetMapCache.unorderedOffsets(source.keySet()), source, new HashMap<K, V>());
+ super(OffsetMapCache.unorderedOffsets(source.keySet()), source, new HashMap<>());
}
Unordered(final Map<K, Integer> offsets, final V[] objects) {
- super(offsets, objects, new HashMap<K, V>());
+ super(offsets, objects, new HashMap<>());
}
@Override
@SuppressWarnings("unchecked")
MutableOffsetMap(final HashMap<K, V> newKeys) {
- this(ImmutableMap.<K, Integer>of(), (V[]) EMPTY_ARRAY, newKeys);
+ this(ImmutableMap.of(), (V[]) EMPTY_ARRAY, newKeys);
}
@SuppressWarnings("unchecked")
private int size;
ReadWriteTrieMap() {
- this.delegate = new TrieMap<K, V>();
+ this.delegate = new TrieMap<>();
this.size = 0;
}
@Override
public final SingletonSet<Entry<K, V>> entrySet() {
- return SingletonSet.<Entry<K, V>>of(new SimpleImmutableEntry<>(keySet.getElement(), value));
+ return SingletonSet.of(new SimpleImmutableEntry<>(keySet.getElement(), value));
}
@Override
if (element == null) {
return (SingletonSet<E>) NULL_SINGLETON;
}
- return new RegularSingletonSet<E>(element);
+ return new RegularSingletonSet<>(element);
}
public abstract E getElement();
private static final Collection<Class<?>> SINGLETON_CLASSES;
static {
- UNMODIFIABLE_COLLECTION_CLASS = Collections.unmodifiableCollection(new ArrayList<Object>()).getClass();
+ UNMODIFIABLE_COLLECTION_CLASS = Collections.unmodifiableCollection(new ArrayList<>()).getClass();
final Builder<Class<?>> b = ImmutableSet.builder();
b.add(Collections.singleton(null).getClass());
public static <V> AsyncNotifyingListenableFutureTask<V> create(final Callable<V> callable,
@Nullable final Executor listenerExecutor) {
if (listenerExecutor != null) {
- return new DelegatingAsyncNotifyingListenableFutureTask<V>(callable, listenerExecutor);
+ return new DelegatingAsyncNotifyingListenableFutureTask<>(callable, listenerExecutor);
} else {
- return new AsyncNotifyingListenableFutureTask<V>(callable);
+ return new AsyncNotifyingListenableFutureTask<>(callable);
}
}
public static <V> AsyncNotifyingListenableFutureTask<V> create(final Runnable runnable, @Nullable final V result,
@Nullable final Executor listenerExecutor) {
if (listenerExecutor != null) {
- return new DelegatingAsyncNotifyingListenableFutureTask<V>(runnable, result, listenerExecutor);
+ return new DelegatingAsyncNotifyingListenableFutureTask<>(runnable, result, listenerExecutor);
} else {
- return new AsyncNotifyingListenableFutureTask<V>(runnable, result);
+ return new AsyncNotifyingListenableFutureTask<>(runnable, result);
}
}
// reached, subsequent tasks will be queued. If the queue is full, tasks will be rejected.
super( maximumPoolSize, maximumPoolSize, keepAliveTime, unit,
- new TrackingLinkedBlockingQueue<Runnable>( maximumQueueSize ) );
+ new TrackingLinkedBlockingQueue<>(maximumQueueSize) );
this.threadPrefix = threadPrefix;
this.maximumQueueSize = maximumQueueSize;
*/
public static <V, X extends Exception> MappingCheckedFuture<V, X> create(
final ListenableFuture<V> delegate, final Function<Exception, X> mapper ) {
- return new MappingCheckedFuture<V, X>( delegate, mapper );
+ return new MappingCheckedFuture<>(delegate, mapper);
}
@Override
@Test(expected=IllegalArgumentException.class)
public void testWrongImmutableConstruction() {
- new ImmutableOffsetMap.Ordered<String, String>(Collections.<String, Integer>emptyMap(), new String[1]);
+ new ImmutableOffsetMap.Ordered<>(Collections.<String, Integer>emptyMap(), new String[1]);
}
@Test
trieMap.put("0", "zero");
trieMap.put("1", "one");
- final ReadWriteTrieMap<String, String> readWriteTrieMap = new ReadWriteTrieMap<String, String>(trieMap, 5);
+ final ReadWriteTrieMap<String, String> readWriteTrieMap = new ReadWriteTrieMap<>(trieMap, 5);
assertNotNull("Object readOnlyTrieMap shouldn't be 'null'.", readWriteTrieMap);
assertTrue("Entry set of readWriteTrieMap and trieMap should by equals.", convertSetEntryToMap(readWriteTrieMap.entrySet()).equals(trieMap));
trieMap.put("2", "two");
- final ReadWriteTrieMap<String, String> readWriteTrieMap2 = new ReadWriteTrieMap<String, String>(trieMap, 4);
+ final ReadWriteTrieMap<String, String> readWriteTrieMap2 = new ReadWriteTrieMap<>(trieMap, 4);
assertFalse("Objects readWriteTrieMap and readOnlyTrieMap2 should be different.", readWriteTrieMap.equals(readWriteTrieMap2));
assertFalse("Hash codes of object readWriteTrieMap and readOnelyTrieMap2 should be different.", readWriteTrieMap.hashCode() == readWriteTrieMap2.hashCode());
CountDownLatch blockLatch = new CountDownLatch( 1 );
executor = new ThreadPoolExecutor( 1, 1, 0, TimeUnit.SECONDS,
- ExecutorServiceUtil.offerFailingBlockingQueue( new LinkedBlockingQueue<Runnable>() ) );
+ ExecutorServiceUtil.offerFailingBlockingQueue(new LinkedBlockingQueue<>() ) );
CountingRejectedExecutionHandler countingHandler =
CountingRejectedExecutionHandler.newCallerRunsPolicy();
CountDownLatch blockLatch = new CountDownLatch( 1 );
executor = new ThreadPoolExecutor( 1, 1, 0, TimeUnit.SECONDS,
- ExecutorServiceUtil.offerFailingBlockingQueue( new LinkedBlockingQueue<Runnable>() ) );
+ ExecutorServiceUtil.offerFailingBlockingQueue(new LinkedBlockingQueue<>() ) );
CountingRejectedExecutionHandler countingHandler =
CountingRejectedExecutionHandler.newAbortPolicy();
TestListener( int expCount, int id ) {
name = "TestListener " + id;
- actual = Collections.synchronizedList( Lists.<N>newArrayListWithCapacity( expCount ) );
+ actual = Collections.synchronizedList( Lists.newArrayListWithCapacity( expCount ) );
reset( expCount );
}
queueExecutor = Executors.newFixedThreadPool( 2 );
NotificationManager<TestListener<Integer>, Integer> manager =
- new QueuedNotificationManager<>( queueExecutor, new TestNotifier<Integer>(),
+ new QueuedNotificationManager<>( queueExecutor, new TestNotifier<>(),
10, "TestMgr" );
int initialCount = 6;
manager.submitNotifications( listener, Arrays.asList( 4, 5 ) );
manager.submitNotification( listener, 6 );
- manager.submitNotifications( null, Collections.<Integer>emptyList() );
+ manager.submitNotifications( null, Collections.emptyList() );
manager.submitNotifications( listener, null );
manager.submitNotification( listener, null );
queueExecutor = Executors.newFixedThreadPool( nListeners );
final ExecutorService stagingExecutor = Executors.newFixedThreadPool( nListeners );
final NotificationManager<TestListener<Integer>, Integer> manager =
- new QueuedNotificationManager<>( queueExecutor, new TestNotifier<Integer>(),
+ new QueuedNotificationManager<>( queueExecutor, new TestNotifier<>(),
5000, "TestMgr" );
final int nNotifications = 100000;
List<TestListener<Integer>> listeners = Lists.newArrayList();
for( int i = 1; i <= nListeners; i++ ) {
final TestListener<Integer> listener =
- i == 2 ? new TestListener2<Integer>( nNotifications, i ) :
- i == 3 ? new TestListener3<Integer>( nNotifications, i ) :
- new TestListener<Integer>( nNotifications, i );
+ i == 2 ? new TestListener2<>(nNotifications, i) :
+ i == 3 ? new TestListener3<>(nNotifications, i) :
+ new TestListener<>(nNotifications, i);
listeners.add( listener );
new Thread( new Runnable() {
queueExecutor = Executors.newFixedThreadPool( 1 );
NotificationManager<TestListener<Integer>, Integer> manager =
- new QueuedNotificationManager<>( queueExecutor, new TestNotifier<Integer>(),
+ new QueuedNotificationManager<>( queueExecutor, new TestNotifier<>(),
10, "TestMgr" );
final CountDownLatch errorCaughtLatch = new CountDownLatch( 1 );
queueExecutor = new ThreadPoolExecutor( 1, 1, 0, TimeUnit.SECONDS,
- new LinkedBlockingQueue<Runnable>() ) {
+ new LinkedBlockingQueue<>() ) {
@Override
public void execute( final Runnable command ) {
super.execute( new Runnable() {
};
NotificationManager<TestListener<Integer>, Integer> manager =
- new QueuedNotificationManager<>( queueExecutor, new TestNotifier<Integer>(),
+ new QueuedNotificationManager<>( queueExecutor, new TestNotifier<>(),
10, "TestMgr" );
TestListener<Integer> listener = new TestListener<>( 2, 1 );
/**
* Tracks if the message from the server has been received
*/
- private SettableFuture<Boolean> messageReceived = SettableFuture.<Boolean>create();
+ private SettableFuture<Boolean> messageReceived = SettableFuture.create();
/**
* Tracks the port on which the server is listening
public WebSocketServer(final int inPort) {
this.inPort = inPort;
- port = SettableFuture.<Integer>create();
+ port = SettableFuture.create();
}
@Override
super(Preconditions.checkNotNull(message), cause);
if (errors != null && errors.length > 0) {
- errorList = ImmutableList.<RpcError>copyOf( Arrays.asList( errors ) );
+ errorList = ImmutableList.copyOf( Arrays.asList( errors ) );
} else {
// Add a default RpcError.
errorList = ImmutableList.of(RpcResultBuilder.newError(ErrorType.APPLICATION, null,
* Returns a builder for a successful result.
*/
public static <T> RpcResultBuilder<T> success() {
- return new RpcResultBuilder<T>( true, null );
+ return new RpcResultBuilder<>(true, null);
}
/**
* @param result the result value
*/
public static <T> RpcResultBuilder<T> success( final T result ) {
- return new RpcResultBuilder<T>( true, result );
+ return new RpcResultBuilder<>(true, result);
}
/**
* Returns a builder for a failed result.
*/
public static <T> RpcResultBuilder<T> failed() {
- return new RpcResultBuilder<T>( false, null );
+ return new RpcResultBuilder<>(false, null);
}
/**
* @param success true if successful, false otherwise.
*/
public static <T> RpcResultBuilder<T> status( final boolean success ) {
- return new RpcResultBuilder<T>( success, null );
+ return new RpcResultBuilder<>(success, null);
}
/**
* @param other the other RpcResult.
*/
public static <T> RpcResultBuilder<T> from( final RpcResult<T> other ) {
- return new RpcResultBuilder<T>( other.isSuccessful(), other.getResult() )
+ return new RpcResultBuilder<>(other.isSuccessful(), other.getResult())
.withRpcErrors( other.getErrors() );
}
private void addError( final RpcError error ) {
if (errors == null) {
- errors = new ImmutableList.Builder<RpcError>();
+ errors = new ImmutableList.Builder<>();
}
errors.add( error );
@Override
public RpcResult<T> build() {
- return new RpcResultImpl<T>( successful, result,
- errors != null ? errors.build() : Collections.<RpcError>emptyList() );
+ return new RpcResultImpl<>(successful, result,
+ errors != null ? errors.build() : Collections.emptyList());
}
/**
assertNotNull( "getErrors returned null", result.getErrors() );
assertEquals( "getErrors size", 0, result.getErrors().size() );
- result = RpcResultBuilder.<String>success( "bar" ).build();
+ result = RpcResultBuilder.success( "bar" ).build();
verifyRpcResult( result, true, "bar" );
}
.withWarning( ErrorType.RPC, "in-use", "message", "my-app-tag", "my-info", cause )
.build();
- RpcResult<String> copy = RpcResultBuilder.<String>from( result )
+ RpcResult<String> copy = RpcResultBuilder.from( result )
.withError( ErrorType.PROTOCOL, "error message" )
.build();
verifyRpcResult( copy, true, "foo" );
import org.opendaylight.yangtools.util.HashCodeBuilder;
final class FixedYangInstanceIdentifier extends YangInstanceIdentifier implements Cloneable {
- static final FixedYangInstanceIdentifier EMPTY_INSTANCE = new FixedYangInstanceIdentifier(ImmutableList.<PathArgument>of(), new HashCodeBuilder<>().build());
+ static final FixedYangInstanceIdentifier EMPTY_INSTANCE = new FixedYangInstanceIdentifier(ImmutableList.of(), new HashCodeBuilder<>().build());
private static final long serialVersionUID = 1L;
private final ImmutableList<PathArgument> path;
private transient volatile YangInstanceIdentifier parent;
}
public static Optional<NormalizedNode<?, ?>> findNode(final NormalizedNode<?, ?> parent, final Iterable<PathArgument> relativePath) {
- return findNode(Optional.<NormalizedNode<?, ?>>fromNullable(parent), relativePath);
+ return findNode(Optional.fromNullable(parent), relativePath);
}
public static Optional<NormalizedNode<?, ?>> findNode(final NormalizedNode<?, ?> parent, final PathArgument... relativePath) {
checkNotNull(tree, "Tree must not be null");
checkNotNull(path, "Path must not be null");
- return findNode(Optional.<NormalizedNode<?, ?>>of(tree), path.getPathArguments());
+ return findNode(Optional.of(tree), path.getPathArguments());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Optional<NormalizedNode<?, ?>> getDataAfter() {
- return Optional.<NormalizedNode<?, ?>>of(data);
+ return Optional.of(data);
}
@Override
* @return Optional with node if the node is present in tree, {@link Optional#absent()} otherwise.
*/
public static <T extends StoreTreeNode<T>> Optional<T> findNode(final T tree, final YangInstanceIdentifier path) {
- Optional<T> current = Optional.<T> of(tree);
+ Optional<T> current = Optional.of(tree);
Iterator<PathArgument> pathIter = path.getPathArguments().iterator();
while (current.isPresent() && pathIter.hasNext()) {
current = current.get().getChild(pathIter.next());
*/
public static <T extends StoreTreeNode<T>> Entry<YangInstanceIdentifier, T> findClosest(final T tree,
final YangInstanceIdentifier path) {
- return findClosestsOrFirstMatch(tree, path, Predicates.<T>alwaysFalse());
+ return findClosestsOrFirstMatch(tree, path, Predicates.alwaysFalse());
}
public static <T extends StoreTreeNode<T>> Entry<YangInstanceIdentifier, T> findClosestsOrFirstMatch(final T tree,
final YangInstanceIdentifier path, final Predicate<T> predicate) {
- Optional<T> parent = Optional.<T>of(tree);
- Optional<T> current = Optional.<T> of(tree);
+ Optional<T> parent = Optional.of(tree);
+ Optional<T> current = Optional.of(tree);
int nesting = 0;
Iterator<PathArgument> pathIter = path.getPathArguments().iterator();
}
if (current.isPresent()) {
final YangInstanceIdentifier currentPath = path.getAncestor(nesting);
- return new SimpleImmutableEntry<YangInstanceIdentifier, T>(currentPath, current.get());
+ return new SimpleImmutableEntry<>(currentPath, current.get());
}
/*
* present. At any rate we verify state just to be on the safe side.
*/
Verify.verify(nesting > 0);
- return new SimpleImmutableEntry<YangInstanceIdentifier, T>(path.getAncestor(nesting - 1), parent.get());
+ return new SimpleImmutableEntry<>(path.getAncestor(nesting - 1), parent.get());
}
public static <T extends StoreTreeNode<T>> Optional<T> getChild(final Optional<T> parent, final PathArgument child) {
YangInstanceIdentifier newID = YangInstanceIdentifier.builder()
.node( NODENAME1 )
- .nodeWithKey( NODENAME2, Collections.<QName,Object>singletonMap( KEY1, "foo" ) )
+ .nodeWithKey( NODENAME2, Collections.singletonMap( KEY1, "foo" ) )
.nodeWithKey( NODENAME3, KEY2, "bar" ).build();
assertNotNull( "InstanceIdentifier is null", newID );
URI path = StreamToNormalizedNodeTest.class.getResource(resourceDirectory).toURI();
final File testDir = new File(path);
final String[] fileList = testDir.list();
- final List<File> testFiles = new ArrayList<File>();
+ final List<File> testFiles = new ArrayList<>();
if (fileList == null) {
throw new FileNotFoundException(resourceDirectory);
}
URI path = StreamToNormalizedNodeTest.class.getResource(resourceDirectory).toURI();
final File testDir = new File(path);
final String[] fileList = testDir.list();
- final List<File> testFiles = new ArrayList<File>();
+ final List<File> testFiles = new ArrayList<>();
if (fileList == null) {
throw new FileNotFoundException(resourceDirectory);
}
static final EmptyStringCodec INSTANCE = new EmptyStringCodec();
private EmptyStringCodec() {
- super(Optional.<EmptyTypeDefinition>absent(), Void.class);
+ super(Optional.absent(), Void.class);
}
@Override
if (dataSchemaNode != null && qname != null) {
for (DataSchemaNode dsn : dataSchemaNode) {
if (qname.isEqualWithoutRevision(dsn.getQName())) {
- return Optional.<DataSchemaNode> of(dsn);
+ return Optional.of(dsn);
} else if (dsn instanceof ChoiceSchemaNode) {
for (ChoiceCaseNode choiceCase : ((ChoiceSchemaNode) dsn).getCases()) {
Optional<DataSchemaNode> foundDsn = findFirstSchema(qname, choiceCase.getChildNodes());
}
public void writeValue(@Nonnull final XMLStreamWriter writer, @Nonnull final SchemaNode schemaNode, final Object value) throws XMLStreamException {
- writeValue(writer, schemaNode, value, Optional.<QNameModule>absent());
+ writeValue(writer, schemaNode, value, Optional.absent());
}
public void writeValue(@Nonnull final XMLStreamWriter writer, @Nonnull final SchemaNode schemaNode, final Object value, final QNameModule parent) throws XMLStreamException {
if (parent.isPresent()) {
write(writer, (IdentityrefTypeDefinition) baseType, value, parent);
} else {
- write(writer, (IdentityrefTypeDefinition) baseType, value, Optional.<QNameModule>absent());
+ write(writer, (IdentityrefTypeDefinition) baseType, value, Optional.absent());
}
} else if (baseType instanceof InstanceIdentifierTypeDefinition) {
write(writer, (InstanceIdentifierTypeDefinition) baseType, value);
}
public void writeValue(@Nonnull final XMLStreamWriter writer, @Nonnull final TypeDefinition<?> type, final Object value) throws XMLStreamException {
- writeValue(writer, type, value, Optional.<QNameModule>absent());
+ writeValue(writer, type, value, Optional.absent());
}
@VisibleForTesting
public void writeValue(@Nonnull final XMLStreamWriter writer, @Nonnull final SchemaNode schemaNode,
final Object value) throws XMLStreamException {
- writeValue(writer, schemaNode, value, Optional.<QNameModule> absent());
+ writeValue(writer, schemaNode, value, Optional.absent());
}
public void writeValue(@Nonnull final XMLStreamWriter writer, @Nonnull final SchemaNode schemaNode,
if (parent.isPresent()) {
write(writer, (IdentityrefTypeDefinition) baseType, value, parent);
} else {
- write(writer, (IdentityrefTypeDefinition) baseType, value, Optional.<QNameModule> absent());
+ write(writer, (IdentityrefTypeDefinition) baseType, value, Optional.absent());
}
} else if (baseType instanceof InstanceIdentifierTypeDefinition) {
write(writer, (InstanceIdentifierTypeDefinition) baseType, value);
public void writeValue(@Nonnull final XMLStreamWriter writer, @Nonnull final TypeDefinition<?> type,
final Object value) throws XMLStreamException {
- writeValue(writer, type, value, Optional.<QNameModule> absent());
+ writeValue(writer, type, value, Optional.absent());
}
@VisibleForTesting
public LeafRefContextTreeBuilder(final SchemaContext schemaContext) {
this.schemaContext = schemaContext;
- this.leafRefs = new LinkedList<LeafRefContext>();
+ this.leafRefs = new LinkedList<>();
}
public LeafRefContext buildLeafRefContextTree() throws IOException,
final LeafRefPath nodeXPath = LeafRefUtils.schemaPathToLeafRefPath(
node.getPath(), module);
- final List<LeafRefContext> foundLeafRefs = new LinkedList<LeafRefContext>();
+ final List<LeafRefContext> foundLeafRefs = new LinkedList<>();
for (final LeafRefContext leafref : leafRefs) {
final LeafRefPath leafRefTargetPath = leafref
public static List<LeafRefContext> findAllLeafRefChilds(
final LeafRefContext parent) {
- final LinkedList<LeafRefContext> leafRefChilds = new LinkedList<LeafRefContext>();
+ final LinkedList<LeafRefContext> leafRefChilds = new LinkedList<>();
if (parent == null) {
return leafRefChilds;
public static List<LeafRefContext> findAllChildsReferencedByLeafRef(
final LeafRefContext parent) {
- final LinkedList<LeafRefContext> childsReferencedByLeafRef = new LinkedList<LeafRefContext>();
+ final LinkedList<LeafRefContext> childsReferencedByLeafRef = new LinkedList<>();
if (parent == null) {
return childsReferencedByLeafRef;
pathFromRoot, root);
if (leafRefReferencedByContext == null) {
- return new HashMap<QName, LeafRefContext>();
+ return new HashMap<>();
}
return leafRefReferencedByContext.getAllReferencedByLeafRefCtxs();
public LeafRefPathParserListenerImpl(final SchemaContext schemaContext, final Module currentModule, final SchemaNode currentNode) {
this.schemaContext = schemaContext;
this.module = currentModule;
- this.leafRefPathQnameList = new LinkedList<QNameWithPredicateBuilder>();
+ this.leafRefPathQnameList = new LinkedList<>();
this.node=currentNode;
this.currentParsingState = ParsingState.LEAF_REF_PATH;
}
@Override
public void enterRel_path_keyexpr(final Rel_path_keyexprContext ctx) {
currentParsingState=ParsingState.PATH_KEY_EXPR;
- predicatePathKeyQnameList = new LinkedList<QNameWithPredicateBuilder>();
+ predicatePathKeyQnameList = new LinkedList<>();
final List<TerminalNode> dots = ctx.DOTS();
for (final TerminalNode parent : dots) {
predicatePathKeyQnameList.add(QNameWithPredicateBuilder.UP_PARENT_BUILDER);
}
public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> orderedLeafSetBuilder(final LeafListSchemaNode schema) {
- return ImmutableOrderedLeafSetNodeSchemaAwareBuilder.<T>create(schema);
+ return ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(schema);
}
public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> leafSetBuilder(final LeafSetNode<T> node) {
}
public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> leafSetBuilder(final LeafListSchemaNode schema) {
- return ImmutableLeafSetNodeSchemaAwareBuilder.<T>create(schema);
+ return ImmutableLeafSetNodeSchemaAwareBuilder.create(schema);
}
public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> leafSetBuilder(final LeafListSchemaNode schema, final LeafSetNode<T> node) {
- return ImmutableLeafSetNodeSchemaAwareBuilder.<T>create(schema, node);
+ return ImmutableLeafSetNodeSchemaAwareBuilder.create(schema, node);
}
public static DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> containerBuilder() {
* @return serialized normalized node for provided instance Id
*/
public static NormalizedNode<?, ?> fromInstanceId(final SchemaContext ctx, final YangInstanceIdentifier id) {
- return fromInstanceId(ctx, id, Optional.<NormalizedNode<?, ?>>absent(), Optional.<Map.Entry<QName, ModifyAction>>absent());
+ return fromInstanceId(ctx, id, Optional.absent(), Optional.absent());
}
/**
* @return serialized normalized node for provided instance Id with overridden last child.
*/
public static NormalizedNode<?, ?> fromInstanceId(final SchemaContext ctx, final YangInstanceIdentifier id, final NormalizedNode<?, ?> deepestElement) {
- return fromInstanceId(ctx, id, Optional.<NormalizedNode<?, ?>>of(deepestElement), Optional.<Map.Entry<QName, ModifyAction>>absent());
+ return fromInstanceId(ctx, id, Optional.of(deepestElement), Optional.absent());
}
/**
public UnorderedMapMixinNormalization(final ListSchemaNode list) {
super(NodeIdentifier.create(list.getQName()));
this.innerNode = new ListItemNormalization(new NodeIdentifierWithPredicates(list.getQName(),
- Collections.<QName, Object>emptyMap()), list);
+ Collections.emptyMap()), list);
}
@Override
}
private static Optional<SchemaNode> tryFindGroupings(final SchemaContext ctx, final QName qname) {
- return Optional.<SchemaNode> fromNullable(Iterables.find(ctx.getGroupings(), new SchemaNodePredicate(qname), null));
+ return Optional.fromNullable(Iterables.find(ctx.getGroupings(), new SchemaNodePredicate(qname), null));
}
private static Optional<SchemaNode> tryFindRpc(final SchemaContext ctx, final QName qname) {
- return Optional.<SchemaNode>fromNullable(Iterables.find(ctx.getOperations(), new SchemaNodePredicate(qname), null));
+ return Optional.fromNullable(Iterables.find(ctx.getOperations(), new SchemaNodePredicate(qname), null));
}
private static Optional<SchemaNode> tryFindNotification(final SchemaContext ctx, final QName qname) {
- return Optional.<SchemaNode>fromNullable(Iterables.find(ctx.getNotifications(), new SchemaNodePredicate(qname), null));
+ return Optional.fromNullable(Iterables.find(ctx.getNotifications(), new SchemaNodePredicate(qname), null));
}
private static final class SchemaNodePredicate implements Predicate<SchemaNode> {
throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
}
- return new ImmutableLeafSetNodeBuilder<T>((ImmutableLeafSetNode<T>) node);
+ return new ImmutableLeafSetNodeBuilder<>((ImmutableLeafSetNode<T>) node);
}
@Override
@Override
public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T value) {
- return withChildValue(value, Collections.<QName,String>emptyMap());
+ return withChildValue(value, Collections.emptyMap());
}
protected final static class ImmutableLeafSetNode<T> extends
throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
}
- return new ImmutableLeafSetNodeSchemaAwareBuilder<T>(schema, (ImmutableLeafSetNode<T>) node);
+ return new ImmutableLeafSetNodeSchemaAwareBuilder<>(schema, (ImmutableLeafSetNode<T>) node);
}
@Override
throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
}
- return new ImmutableOrderedLeafSetNodeBuilder<T>((ImmutableOrderedLeafSetNode<T>) node);
+ return new ImmutableOrderedLeafSetNodeBuilder<>((ImmutableOrderedLeafSetNode<T>) node);
}
private void checkDirty() {
@Override
public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T value) {
- return withChildValue(value, Collections.<QName,String>emptyMap());
+ return withChildValue(value, Collections.emptyMap());
}
protected static final class ImmutableOrderedLeafSetNode<T> extends
throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
}
- return new ImmutableOrderedLeafSetNodeSchemaAwareBuilder<T>(schema, (ImmutableOrderedLeafSetNode<T>) node);
+ return new ImmutableOrderedLeafSetNodeSchemaAwareBuilder<>(schema, (ImmutableOrderedLeafSetNode<T>) node);
}
@Override
@Override
public final Optional<DataContainerChild<? extends PathArgument, ?>> getChild(final PathArgument child) {
- return Optional.<DataContainerChild<? extends PathArgument, ?>> fromNullable(children.get(child));
+ return Optional.fromNullable(children.get(child));
}
@Override
public O parse(Iterable<E> childNodes, S schema) {
CollectionNodeBuilder<N, O> listBuilder = provideBuilder(schema);
- buildingStrategy.prepareAttributes(Collections.<QName, String>emptyMap(), listBuilder);
+ buildingStrategy.prepareAttributes(Collections.emptyMap(), listBuilder);
for (E childNode : childNodes) {
N listChild = getListEntryNodeParser().parse(Collections.singletonList(childNode), schema);
/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Cisco Systems, Inc. and others. 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,
}
protected final Optional<NormalizedNode<?, ?>> dataOptional() {
- return Optional.<NormalizedNode<?, ?>>of(data);
+ return Optional.of(data);
}
@Override
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
abstract class AbstractDataTreeTip implements DataTreeTip {
- private static final YangInstanceIdentifier PUBLIC_ROOT_PATH = YangInstanceIdentifier.create(Collections.<PathArgument>emptyList());
+ private static final YangInstanceIdentifier PUBLIC_ROOT_PATH = YangInstanceIdentifier.create(Collections.emptyList());
/**
* Return the current root node of this tip.
}
protected final Optional<NormalizedNode<?, ?>> dataOptional() {
- return Optional.<NormalizedNode<?, ?>>of(data);
+ return Optional.of(data);
}
@Override
/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Cisco Systems, Inc. and others. 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,
private static Optional<NormalizedNode<?, ?>> optionalData(final TreeNode meta) {
if (meta != null) {
- return Optional.<NormalizedNode<?,?>>of(meta.getData());
+ return Optional.of(meta.getData());
} else {
return Optional.absent();
}
LOG.trace("Resolving modification apply strategy for {}", path);
upgradeIfPossible();
- return StoreTreeNodes.<ModificationApplyOperation>findNodeChecked(strategyTree, path);
+ return StoreTreeNodes.findNodeChecked(strategyTree, path);
}
private OperationWithModification resolveModificationFor(final YangInstanceIdentifier path) {
}
private Optional<TreeNode> metadataFromSnapshot(@Nonnull final PathArgument child) {
- return original.isPresent() ? original.get().getChild(child) : Optional.<TreeNode>absent();
+ return original.isPresent() ? original.get().getChild(child) : Optional.absent();
}
private Optional<TreeNode> metadataFromData(@Nonnull final PathArgument child, final Version modVersion) {
@SuppressWarnings({ "unchecked", "rawtypes" })
OrderedLeafSetModificationStrategy(final LeafListSchemaNode schema, final TreeType treeType) {
super((Class) LeafSetNode.class, treeType);
- entryStrategy = Optional.<ModificationApplyOperation> of(new LeafSetEntryModificationStrategy(schema));
+ entryStrategy = Optional.of(new LeafSetEntryModificationStrategy(schema));
}
@Override
OrderedMapModificationStrategy(final ListSchemaNode schema, final TreeType treeType) {
super(OrderedMapNode.class, treeType);
- entryStrategy = Optional.<ModificationApplyOperation> of(new ListEntryModificationStrategy(schema, treeType));
+ entryStrategy = Optional.of(new ListEntryModificationStrategy(schema, treeType));
}
@Override
@Override
public Optional<NormalizedNode<?, ?>> getDataBefore() {
- return Optional.<NormalizedNode<?, ?>>of(oldData);
+ return Optional.of(oldData);
}
@Override
@Override
public Optional<NormalizedNode<?, ?>> getDataBefore() {
- return Optional.<NormalizedNode<?, ?>>of(oldData);
+ return Optional.of(oldData);
}
}
\ No newline at end of file
case DELETE:
// Deletion of a non-existing node is a no-op, report it as such
modification.resolveModificationType(currentMeta.isPresent() ? ModificationType.DELETE : ModificationType.UNMODIFIED);
- return modification.setSnapshot(Optional.<TreeNode> absent());
+ return modification.setSnapshot(Optional.absent());
case TOUCH:
Preconditions.checkArgument(currentMeta.isPresent(), "Metadata not available for modification %s",
modification);
private final Optional<ModificationApplyOperation> entryStrategy;
UnkeyedListModificationStrategy(final ListSchemaNode schema, final TreeType treeType) {
- entryStrategy = Optional.<ModificationApplyOperation> of(new UnkeyedListItemModificationStrategy(schema, treeType));
+ entryStrategy = Optional.of(new UnkeyedListItemModificationStrategy(schema, treeType));
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
UnorderedLeafSetModificationStrategy(final LeafListSchemaNode schema, final TreeType treeType) {
super((Class) LeafSetNode.class, treeType);
- entryStrategy = Optional.<ModificationApplyOperation> of(new LeafSetEntryModificationStrategy(schema));
+ entryStrategy = Optional.of(new LeafSetEntryModificationStrategy(schema));
}
@SuppressWarnings("rawtypes")
UnorderedMapModificationStrategy(final ListSchemaNode schema, final TreeType treeType) {
super(MapNode.class, treeType);
- entryStrategy = Optional.<ModificationApplyOperation>of(new ListEntryModificationStrategy(schema, treeType));
+ entryStrategy = Optional.of(new ListEntryModificationStrategy(schema, treeType));
}
@SuppressWarnings("rawtypes")
QName name = getAttrQName("namespace", "2012-12-12", "attr", Optional.of("prefix"));
final Map.Entry<QName, String> attributeEntry = new AbstractMap.SimpleEntry<>(name, "value");
- name = getAttrQName("namespace2", "2012-12-12", "attr", Optional.<String>absent());
+ name = getAttrQName("namespace2", "2012-12-12", "attr", Optional.absent());
final Map.Entry<QName, String> attributeEntryNoPrefix = new AbstractMap.SimpleEntry<>(name, "value");
final RandomPrefix randomPrefix = new RandomPrefix();
QName name = getAttrQName("namespace", "2012-12-12", "attr", Optional.of("prefix"));
final Map.Entry<QName, String> attributeEntry = new AbstractMap.SimpleEntry<>(name, "value");
- name = getAttrQName("namespace2", "2012-12-12", "attr", Optional.<String> absent());
+ name = getAttrQName("namespace2", "2012-12-12", "attr", Optional.absent());
final Map.Entry<QName, String> attributeEntryNoPrefix = new AbstractMap.SimpleEntry<>(name, "value");
final RandomPrefix randomPrefix = new RandomPrefix();
private static void writeIntoMapEntry() {
- final Map<QName, Object> keys = new HashMap<QName, Object>();
+ final Map<QName, Object> keys = new HashMap<>();
keys.put(name, "New Project");
final NodeIdentifierWithPredicates mapEntryPath = new NodeIdentifierWithPredicates(
project, keys);
private static void writeMapEntry() {
- final Map<QName, Object> keys = new HashMap<QName, Object>();
+ final Map<QName, Object> keys = new HashMap<>();
keys.put(name, "New Project");
final NodeIdentifierWithPredicates mapEntryPath = new NodeIdentifierWithPredicates(
project, keys);
private static void writeIntoMapEntry() {
- final Map<QName, Object> keys = new HashMap<QName, Object>();
+ final Map<QName, Object> keys = new HashMap<>();
keys.put(name, "New Project");
final NodeIdentifierWithPredicates mapEntryPath = new NodeIdentifierWithPredicates(
project, keys);
private static void writeMapEntry() {
- final Map<QName, Object> keys = new HashMap<QName, Object>();
+ final Map<QName, Object> keys = new HashMap<>();
keys.put(name, "New Project");
final NodeIdentifierWithPredicates mapEntryPath = new NodeIdentifierWithPredicates(
project, keys);
public void immutableOrderedMapBuilderTest() {
final LinkedList<MapEntryNode> mapEntryNodeColl = new LinkedList();
mapEntryNodeColl.add(LIST_MAIN_CHILD_3);
- final Map<QName, Object> keys = new HashMap<QName, Object>();
+ final Map<QName, Object> keys = new HashMap<>();
keys.put(LIST_MAIN_CHILD_QNAME_1, 1);
final YangInstanceIdentifier.NodeIdentifierWithPredicates mapEntryPath = new YangInstanceIdentifier
.NodeIdentifierWithPredicates(LIST_MAIN, keys);
assertTrue(serialized.contains("bar"));
assertEquals("serialize", "",
- codec.serialize(ImmutableSet.<String> of()));
+ codec.serialize(ImmutableSet.of()));
assertEquals("serialize", "", codec.serialize(null));
}
}
return EnumerationType.create( mock( SchemaPath.class ), enumList,
- Optional.<EnumTypeDefinition.EnumPair>absent() );
+ Optional.absent() );
}
public static UnionTypeDefinition toUnionTypeDefinition( TypeDefinition<?>... types ) {
public UnorderedMapMixinContextNode(final ListSchemaNode list) {
super(NodeIdentifier.create(list.getQName()), list);
this.innerNode = new ListItemContextNode(new NodeIdentifierWithPredicates(list.getQName(),
- Collections.<QName, Object> emptyMap()), list);
+ Collections.emptyMap()), list);
}
@Override
}
public SchemaResolutionException(@Nonnull final String message, final Throwable cause) {
- this(message, cause, Collections.<SourceIdentifier>emptySet(), ImmutableMultimap.<SourceIdentifier, ModuleImport>of());
+ this(message, cause, Collections.emptySet(), ImmutableMultimap.of());
}
public SchemaResolutionException(@Nonnull final String message, final Collection<SourceIdentifier> resolvedSources,
*/
SchemaSourceFilter ALWAYS_ACCEPT = new SchemaSourceFilter() {
private final Iterable<Class<? extends SchemaSourceRepresentation>> representations =
- Collections.<Class<? extends SchemaSourceRepresentation>>singletonList(SchemaSourceRepresentation.class);
+ Collections.singletonList(SchemaSourceRepresentation.class);
private final ListenableFuture<Boolean> applyFuture = Futures.immediateFuture(Boolean.TRUE);
@Override
public static SourceIdentifier identifierFromFilename(final String name) {
checkArgument(name.endsWith(".yang"), "Filename %s does not have a .yang extension", name);
// FIXME: add revision-awareness
- return SourceIdentifier.create(name.substring(0, name.length() - 5), Optional.<String>absent());
+ return SourceIdentifier.create(name.substring(0, name.length() - 5), Optional.absent());
}
/**
public static SourceIdentifier identifierFromFilename(final String name) {
checkArgument(name.endsWith(".yin"), "Filename %s does not have a .yin extension", name);
// FIXME: add revision-awareness
- return SourceIdentifier.create(name.substring(0, name.length() - 4), Optional.<String>absent());
+ return SourceIdentifier.create(name.substring(0, name.length() - 4), Optional.absent());
}
/**
@Before
public void init() {
schemaRegistry = new SharedSchemaRepository("test");
- fileSourceProvider = new FilesystemSchemaSourceCache<YangTextSchemaSource>(schemaRegistry,
+ fileSourceProvider = new FilesystemSchemaSourceCache<>(schemaRegistry,
YangTextSchemaSource.class, TEST_MODELS_FOLDER);
final TextToASTTransformer astTransformer = TextToASTTransformer.create(schemaRegistry, schemaRegistry);
schemaRegistry.registerSchemaSourceListener(astTransformer);
public <T extends SchemaSourceRepresentation> CheckedFuture<T, SchemaSourceException> getSchemaSource(final SourceIdentifier id, final Class<T> representation) {
final ListMultimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> srcs = sources.get(id);
if (srcs == null) {
- return Futures.<T, SchemaSourceException>immediateFailedCheckedFuture(new MissingSchemaSourceException("No providers registered for source" + id, id));
+ return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException("No providers registered for source" + id, id));
}
// TODO, remove and make sources keep sorted multimap (e.g. ArrayListMultimap with SortedLists)
final Iterator<AbstractSchemaSourceRegistration<?>> regs = sortedSchemaSourceRegistrations.iterator();
if (!regs.hasNext()) {
- return Futures.<T, SchemaSourceException>immediateFailedCheckedFuture(
+ return Futures.immediateFailedCheckedFuture(
new MissingSchemaSourceException("No providers for source " + id + " representation " + representation + " available", id));
}
m.put(source.getRepresentation(), reg);
- final Collection<PotentialSchemaSource<?>> reps = Collections.<PotentialSchemaSource<?>>singleton(source);
+ final Collection<PotentialSchemaSource<?>> reps = Collections.singleton(source);
for (SchemaListenerRegistration l : listeners) {
l.getInstance().schemaSourceRegistered(reps);
}
// Init storage adapters
private static final Map<Class<? extends SchemaSourceRepresentation>, StorageAdapter<? extends SchemaSourceRepresentation>> STORAGE_ADAPTERS =
- Collections.<Class<? extends SchemaSourceRepresentation>, StorageAdapter<? extends SchemaSourceRepresentation>> singletonMap(
+ Collections.singletonMap(
YangTextSchemaSource.class, new YangTextSchemaStorageAdapter());
private static final Pattern CACHED_FILE_PATTERN =
}
LOG.debug("Source {} not found in cache as {}", sourceIdentifier, file);
- return Futures.<T, SchemaSourceException>immediateFailedCheckedFuture(new MissingSchemaSourceException("Source not found", sourceIdentifier));
+ return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException("Source not found", sourceIdentifier));
}
@Override
@Beta
public class InMemorySchemaSourceCache<T extends SchemaSourceRepresentation> extends AbstractSchemaSourceCache<T> implements AutoCloseable {
- private final List<FinalizablePhantomReference<T>> regs = Collections.synchronizedList(new ArrayList<FinalizablePhantomReference<T>>());
+ private final List<FinalizablePhantomReference<T>> regs = Collections.synchronizedList(new ArrayList<>());
private final FinalizableReferenceQueue queue = new FinalizableReferenceQueue();
private final Cache<SourceIdentifier, T> cache;
return Futures.immediateCheckedFuture(present);
}
- return Futures.<T, SchemaSourceException>immediateFailedCheckedFuture(new MissingSchemaSourceException("Source not found", sourceIdentifier));
+ return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException("Source not found", sourceIdentifier));
}
@Override
@Override
public Set<Module> findModuleByNamespace(final URI namespace) {
final Set<Module> ret = getNamespaceToModules().get(namespace);
- return ret == null ? Collections.<Module>emptySet() : ret;
+ return ret == null ? Collections.emptySet() : ret;
}
@Override
*/
@Deprecated
public static Optional<TypeDefinition<?>> defaultBaseTypeFor(final String typeName) {
- return Optional.<TypeDefinition<?>> fromNullable(defaultBaseTypeForImpl(typeName));
+ return Optional.fromNullable(defaultBaseTypeForImpl(typeName));
}
@Deprecated
final Builder<Module> filteredModulesBuilder = new Builder<>();
- final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(new TreeMap<URI, Collection<Module>>(), MODULE_SET_SUPPLIER);
- final SetMultimap<String, Module> nameMap = Multimaps.newSetMultimap(new TreeMap<String, Collection<Module>>(), MODULE_SET_SUPPLIER);
+ final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(new TreeMap<>(), MODULE_SET_SUPPLIER);
+ final SetMultimap<String, Module> nameMap = Multimaps.newSetMultimap(new TreeMap<>(), MODULE_SET_SUPPLIER);
ImmutableMap.Builder<ModuleIdentifier, String> identifiersToSourcesBuilder = ImmutableMap.builder();
Preconditions.checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
Preconditions.checkArgument(xpath != null, "XPath string reference cannot be NULL");
- final List<QName> path = new LinkedList<QName>();
+ final List<QName> path = new LinkedList<>();
for (final String pathComponent : SLASH_SPLITTER.split(xpath)) {
if (!pathComponent.isEmpty()) {
path.add(stringPathPartToQName(context, parentModule, pathComponent));
abstract class AbstractBaseType<T extends TypeDefinition<T>> extends AbstractTypeDefinition<T> {
AbstractBaseType(final QName qname) {
- this(SchemaPath.create(true, qname), ImmutableList.<UnknownSchemaNode>of());
+ this(SchemaPath.create(true, qname), ImmutableList.of());
}
AbstractBaseType(final SchemaPath path, final List<UnknownSchemaNode> unknownSchemaNodes) {
AbstractRangedBaseType(final QName qname, final Number minValue, final Number maxValue) {
super(qname);
- this.rangeConstraints = ImmutableList.<RangeConstraint>of(BaseConstraints.newRangeConstraint(
- minValue, maxValue, Optional.<String>absent(), Optional.<String>absent()));
+ this.rangeConstraints = ImmutableList.of(BaseConstraints.newRangeConstraint(
+ minValue, maxValue, Optional.absent(), Optional.absent()));
}
AbstractRangedBaseType(final SchemaPath path, final List<UnknownSchemaNode> unknownSchemaNodes,
private static List<RangeConstraint> createRangeConstraint(final String min, final String max) {
return ImmutableList.of(BaseConstraints.newRangeConstraint(new BigDecimal(min), new BigDecimal(max),
- Optional.<String>absent(), Optional.of("https://tools.ietf.org/html/rfc6020#section-9.3.4")));
+ Optional.absent(), Optional.of("https://tools.ietf.org/html/rfc6020#section-9.3.4")));
}
static List<RangeConstraint> constraintsForDigits(final int fractionDigits) {
}
static final List<LengthConstraint> INTEGER_SIZE_CONSTRAINTS = ImmutableList.of(
- BaseConstraints.newLengthConstraint(0, Integer.MAX_VALUE, Optional.<String>absent(), Optional.<String>absent()));
+ BaseConstraints.newLengthConstraint(0, Integer.MAX_VALUE, Optional.absent(), Optional.absent()));
}
@Test
public void schemaSourceTransformerTest() {
- this.schema = new SchemaSourceTransformer<YangSchemaSourceRepresentation, YinXmlSchemaSource>(
- this.provider, SchemaSourceTransformerTest.SRC_CLASS, this.consumer, SchemaSourceTransformerTest.DST_CLASS, this.function);
+ this.schema = new SchemaSourceTransformer<>(
+ this.provider, SchemaSourceTransformerTest.SRC_CLASS, this.consumer,
+ SchemaSourceTransformerTest.DST_CLASS, this.function);
Assert.assertNotNull(this.schema);
}
final Registrator reg = new Registrator(p, SchemaSourceTransformerTest.SRC_CLASS, PotentialSchemaSource.Costs.IMMEDIATE);
final SourceIdentifier sourceIdentifier = new SourceIdentifier("source");
reg.register(sourceIdentifier);
- this.schema = new SchemaSourceTransformer<YangSchemaSourceRepresentation, YinXmlSchemaSource>(p,
+ this.schema = new SchemaSourceTransformer<>(p,
SchemaSourceTransformerTest.SRC_CLASS, this.consumer, SchemaSourceTransformerTest.DST_CLASS,
this.function);
final SchemaSourceProvider<YinXmlSchemaSource> provider = this.schema;
reg.register(sourceIdentifier);
final Consumer c = new Consumer();
- this.schema = new SchemaSourceTransformer<YangSchemaSourceRepresentation, YinXmlSchemaSource>(p,
+ this.schema = new SchemaSourceTransformer<>(p,
SchemaSourceTransformerTest.SRC_CLASS, c, SchemaSourceTransformerTest.DST_CLASS, this.function);
final SchemaSourceListener listener = this.schema;
assertFalse("mdiA shouldn't equal to mdiB", mdiA.equals(mdiB));
// //description
- mdiA = MustDefinitionImpl.create("mustStr", Optional.<String>absent(), reference, errorAppTag, errorMessage);
+ mdiA = MustDefinitionImpl.create("mustStr", Optional.absent(), reference, errorAppTag, errorMessage);
mdiB = MustDefinitionImpl.create("mustStr", description, reference, errorAppTag, errorMessage);
assertFalse("mdiA shouldn't equal to mdiB", mdiA.equals(mdiB));
assertFalse("mdiA shouldn't equal to mdiB", mdiA.equals(mdiB));
// //reference
- mdiA = MustDefinitionImpl.create("mustStr", description, Optional.<String>absent(), errorAppTag, errorMessage);
+ mdiA = MustDefinitionImpl.create("mustStr", description, Optional.absent(), errorAppTag, errorMessage);
mdiB = MustDefinitionImpl.create("mustStr", description, reference, errorAppTag, errorMessage);
assertFalse("mdiA shouldn't equal to mdiB", mdiA.equals(mdiB));
Set<NotificationBuilder> notifications = module.getAddedNotifications();
for (NotificationBuilder notification : notifications) {
if (notification.getQName().equals(child)) {
- return Optional.<SchemaNodeBuilder> of(notification);
+ return Optional.of(notification);
}
}
Set<RpcDefinitionBuilder> rpcs = module.getAddedRpcs();
for (RpcDefinitionBuilder rpc : rpcs) {
if (rpc.getQName().equals(child)) {
- return Optional.<SchemaNodeBuilder> of(rpc);
+ return Optional.of(rpc);
}
}
LOG.trace("Child {} not found in data namespace of module {}", child, module);
private static Optional<SchemaNodeBuilder> getDataChildByQName(final DataNodeContainerBuilder builder, final QName child) {
for (DataSchemaNodeBuilder childNode : builder.getChildNodeBuilders()) {
if (childNode.getQName().equals(child)) {
- return Optional.<SchemaNodeBuilder> of(childNode);
+ return Optional.of(childNode);
}
}
LOG.trace(CHILD_NOT_FOUND_IN_NODE_STR, child, builder);
configuration = base.isConfiguration();
augmentations.addAll(base.getAvailableAugmentations());
- Set<DataSchemaNodeBuilder> wrapped = BuilderUtils.wrapChildNodes(moduleName, line, new HashSet<DataSchemaNode>(
+ Set<DataSchemaNodeBuilder> wrapped = BuilderUtils.wrapChildNodes(moduleName, line, new HashSet<>(
base.getCases()), path, qname);
for (DataSchemaNodeBuilder wrap : wrapped) {
if (wrap instanceof ChoiceCaseBuilder) {
private ModuleImpl instance;
private final String name;
private final String sourcePath;
- private static final SchemaPath SCHEMA_PATH = SchemaPath.create(Collections.<QName> emptyList(), true);
+ private static final SchemaPath SCHEMA_PATH = SchemaPath.create(Collections.emptyList(), true);
private String prefix;
private QNameModule qnameModule = EMPTY_QNAME_MODULE;
super(builder);
this.name = checkNotNull(name, "Missing name");
this.sourcePath = sourcePath; //TODO: can this be nullable?
- this.imports = ImmutableSet.<ModuleImport> copyOf(builder.imports.values());
- this.submodules = ImmutableSet.<Module> copyOf(builder.submodules);
+ this.imports = ImmutableSet.copyOf(builder.imports.values());
+ this.submodules = ImmutableSet.copyOf(builder.submodules);
this.prefix = builder.getPrefix();
this.qnameModule = QNameModule.create(builder.getNamespace(),
*/
public static Set<String> createListKey(final Key_stmtContext ctx) {
final String keyDefinition = stringFromNode(ctx);
- return Sets.<String>newLinkedHashSet(KEYDEF_SPLITTER.split(keyDefinition));
+ return Sets.newLinkedHashSet(KEYDEF_SPLITTER.split(keyDefinition));
}
/**
baseType = uintType;
} else if ("enumeration".equals(typeName)) {
List<EnumTypeDefinition.EnumPair> enumConstants = getEnumConstants(typeBody, actualPath, moduleName);
- return EnumerationType.create(baseTypePath, enumConstants, Optional.<EnumPair> absent());
+ return EnumerationType.create(baseTypePath, enumConstants, Optional.absent());
} else if ("string".equals(typeName)) {
StringTypeDefinition stringType = StringType.getInstance();
constraints.addLengths(stringType.getLengthConstraints());
* Invest some quality time in building up lookup tables for both.
*/
final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(
- new TreeMap<URI, Collection<Module>>(), MODULE_SET_SUPPLIER);
+ new TreeMap<>(), MODULE_SET_SUPPLIER);
final SetMultimap<String, Module> nameMap = Multimaps.newSetMultimap(
- new TreeMap<String, Collection<Module>>(), MODULE_SET_SUPPLIER);
+ new TreeMap<>(), MODULE_SET_SUPPLIER);
for (Module m : modules) {
nameMap.put(m.getName(), m);
public SchemaContext parseFiles(final Collection<File> yangFiles, final SchemaContext context) throws IOException,
YangSyntaxErrorException {
if (yangFiles == null) {
- return resolveSchemaContext(Collections.<Module> emptySet());
+ return resolveSchemaContext(Collections.emptySet());
}
Collection<ByteSource> sources = BuilderUtils.filesToByteSources(yangFiles);
public SchemaContext parseSources(final Collection<ByteSource> sources, final SchemaContext context)
throws IOException, YangSyntaxErrorException {
if (sources == null) {
- return resolveSchemaContext(Collections.<Module> emptySet());
+ return resolveSchemaContext(Collections.emptySet());
}
final List<ModuleBuilder> sorted = resolveModuleBuilders(sources, context);
// Conflicting elements in other namespaces are still not present
// since resolveUsesAugment occurs before augmenting from external
// modules.
- potentialTargetNode = Optional.<SchemaNodeBuilder> fromNullable(findTargetNode(augment.getTargetPath()
+ potentialTargetNode = Optional.fromNullable(findTargetNode(augment.getTargetPath()
.getPathFromRoot(), parentNode));
}
return new DependencyResolver(resolved, pending, imports);
} else {
- return new DependencyResolver(resolved, Collections.<SourceIdentifier>emptyList(), ImmutableMultimap.<SourceIdentifier, ModuleImport>of());
+ return new DependencyResolver(resolved, Collections.emptyList(), ImmutableMultimap.of());
}
}
private final Collection<SourceIdentifier> requiredSources = new ConcurrentLinkedDeque<>();
private final Multimap<SourceIdentifier, YangTextSchemaSource> texts = ArrayListMultimap.create();
private final AtomicReference<Optional<SchemaContext>> currentSchemaContext =
- new AtomicReference<>(Optional.<SchemaContext>absent());
+ new AtomicReference<>(Optional.absent());
private final InMemorySchemaSourceCache<ASTSchemaSource> cache;
private final SchemaListenerRegistration transReg;
private final SchemaSourceRegistry registry;
public YangTextSchemaSourceRegistration registerSource(@Nonnull final URL url) throws SchemaSourceException, IOException, YangSyntaxErrorException {
checkArgument(url != null, "Supplied URL must not be null");
- final SourceIdentifier guessedId = new SourceIdentifier(url.getFile(), Optional.<String>absent());
+ final SourceIdentifier guessedId = new SourceIdentifier(url.getFile(), Optional.absent());
return registerSource(new YangTextSchemaSource(guessedId) {
@Override
public InputStream openStream() throws IOException {
LOG.debug("Lookup {} result {}", sourceIdentifier, ret);
if (ret.isEmpty()) {
- return Futures.<YangTextSchemaSource, SchemaSourceException>immediateFailedCheckedFuture(
+ return Futures.immediateFailedCheckedFuture(
new MissingSchemaSourceException("URL for " + sourceIdentifier + " not registered", sourceIdentifier));
}
public final class StatementSupportBundle implements Immutable,NamespaceBehaviour.Registry {
- private static final StatementSupportBundle EMPTY = new StatementSupportBundle(null, ImmutableMap.<QName, StatementSupport<?, ?, ?>>of(), ImmutableMap.<Class<?>, NamespaceBehaviour<?, ?, ?>>of());
+ private static final StatementSupportBundle EMPTY = new StatementSupportBundle(null, ImmutableMap.of(), ImmutableMap.of());
private final StatementSupportBundle parent;
private final ImmutableMap<QName, StatementSupport<?,?,?>> definitions;
/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Cisco Systems, Inc. and others. 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,
private <K, C extends StmtContext<?,?,?>, N extends StatementNamespace<K, ?, ?>> AbstractPrerequisite<C> requiresCtxImpl(final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key,final ModelProcessingPhase phase) {
checkNotRegistered();
try {
- AddedToNamespace<C> addedToNs = new AddedToNamespace<C>(phase);
+ AddedToNamespace<C> addedToNs = new AddedToNamespace<>(phase);
addReq(addedToNs);
contextImpl(context).onNamespaceItemAddedAction((Class) namespace,key,addedToNs);
return addedToNs;
private <C extends StmtContext<?, ?, ?>> AbstractPrerequisite<C> requiresCtxImpl(final C context, final ModelProcessingPhase phase) {
Preconditions.checkState(action == null, "Action was already registered.");
try {
- PhaseFinished<C> phaseFin = new PhaseFinished<C>();
+ PhaseFinished<C> phaseFin = new PhaseFinished<>();
addReq(phaseFin);
contextImpl(context).addPhaseCompletedListener(phase,phaseFin);
return phaseFin;
private <K, C extends StmtContext.Mutable<?, ?, ?> , N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>> AbstractPrerequisite<C> mutatesCtxImpl(
final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key, final ModelProcessingPhase phase) {
try {
- PhaseModificationInNamespace<C> mod = new PhaseModificationInNamespace<C>(phase);
+ PhaseModificationInNamespace<C> mod = new PhaseModificationInNamespace<>(phase);
addReq(mod);
addMutation(mod);
contextImpl(context).onNamespaceItemAddedAction((Class) namespace,key,mod);
@Override
public <C extends Mutable<?, ?, ?>, CT extends C> Prerequisite<C> mutatesCtx(final CT context, final ModelProcessingPhase phase) {
try {
- return addMutation(new PhaseMutation<C>(contextImpl(context),phase));
+ return addMutation(new PhaseMutation<>(contextImpl(context), phase));
} catch (InferenceException e) {
throw shouldNotHappenProbablyBug(e);
}
@Override
public <D extends DeclaredStatement<?>> Prerequisite<D> requiresDeclared(final StmtContext<?, ? extends D, ?> context) {
- return requiresCtxImpl(context, FULL_DECLARATION).transform(StmtContextUtils.<D>buildDeclared());
+ return requiresCtxImpl(context, FULL_DECLARATION).transform(StmtContextUtils.buildDeclared());
}
@Override
public <K, D extends DeclaredStatement<?>, N extends StatementNamespace<K, ? extends D, ?>> Prerequisite<D> requiresDeclared(
final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) {
final AbstractPrerequisite<StmtContext<?,D,?>> rawContext = requiresCtxImpl(context, namespace, key, FULL_DECLARATION);
- return rawContext.transform(StmtContextUtils.<D>buildDeclared());
+ return rawContext.transform(StmtContextUtils.buildDeclared());
}
@Override
public <E extends EffectiveStatement<?, ?>> Prerequisite<E> requiresEffective(final StmtContext<?, ?, ? extends E> stmt) {
- return requiresCtxImpl(stmt, EFFECTIVE_MODEL).transform(StmtContextUtils.<E>buildEffective());
+ return requiresCtxImpl(stmt, EFFECTIVE_MODEL).transform(StmtContextUtils.buildEffective());
}
@Override
public <K, E extends EffectiveStatement<?, ?>, N extends StatementNamespace<K, ?, ? extends E>> Prerequisite<E> requiresEffective(
final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) {
final AbstractPrerequisite<StmtContext<?,?,E>> rawContext = requiresCtxImpl(context, namespace, key, EFFECTIVE_MODEL);
- return rawContext.transform(StmtContextUtils.<E>buildEffective());
+ return rawContext.transform(StmtContextUtils.buildEffective());
}
public <N extends IdentifierNamespace<?, ?>> Prerequisite<Mutable<?, ?, ?>> mutatesNs(final Mutable<?, ?, ?> context,
final Class<N> namespace) {
try {
- return addMutation(new NamespaceMutation<N>(contextImpl(context),namespace));
+ return addMutation(new NamespaceMutation<>(contextImpl(context), namespace));
} catch (SourceException e) {
throw shouldNotHappenProbablyBug(e);
}
private static ModuleIdentifier getModuleIdentifier(
final StmtContext.Mutable<String, BelongsToStatement, EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
String moduleName = belongsToCtx.getStatementArgument();
- return new ModuleIdentifierImpl(moduleName, Optional.<URI> absent(),
+ return new ModuleIdentifierImpl(moduleName, Optional.absent(),
Optional.of(SimpleDateFormatUtil.DEFAULT_BELONGS_TO_DATE));
}
revision = SimpleDateFormatUtil.DEFAULT_DATE_IMP;
}
- return new ModuleIdentifierImpl(stmt.getStatementArgument(), Optional.<URI> absent(),
- Optional.<Date> of(revision));
+ return new ModuleIdentifierImpl(stmt.getStatementArgument(), Optional.absent(),
+ Optional.of(revision));
}
}
\ No newline at end of file
revisionDate = SimpleDateFormatUtil.DEFAULT_DATE_IMP;
}
- return new ModuleIdentifierImpl(subModuleName, Optional.<URI> absent(), Optional.<Date> of(revisionDate));
+ return new ModuleIdentifierImpl(subModuleName, Optional.absent(), Optional.of(revisionDate));
}
@Override
QNameModule qNameModule = QNameModule.create(moduleNs.get(), revisionDate.orNull()).intern();
ModuleIdentifier moduleIdentifier = new ModuleIdentifierImpl(stmt.getStatementArgument(),
- Optional.<URI> absent(), revisionDate);
+ Optional.absent(), revisionDate);
stmt.addContext(ModuleNamespace.class, moduleIdentifier, stmt);
stmt.addContext(ModuleNamespaceForBelongsTo.class, moduleIdentifier.getName(), stmt);
return null;
}
- return new PatternConstraintEffectiveImpl(pattern, Optional.<String>absent(), Optional.<String>absent());
+ return new PatternConstraintEffectiveImpl(pattern, Optional.absent(), Optional.absent());
}
@Override
Utils.getLatestRevision(stmt.declaredSubstatements())).or(DEFAULT_REVISION);
ModuleIdentifier submoduleIdentifier = new ModuleIdentifierImpl(stmt.getStatementArgument(),
- Optional.<URI> absent(), revisionDate);
+ Optional.absent(), revisionDate);
stmt.addContext(SubmoduleNamespace.class, submoduleIdentifier, stmt);
throw new UnsupportedOperationException("Utility class");
}
- public static final Set<StatementDefinition> SUPPORTED_REFINE_SUBSTATEMENTS = ImmutableSet.<StatementDefinition>of(
+ public static final Set<StatementDefinition> SUPPORTED_REFINE_SUBSTATEMENTS = ImmutableSet.of(
Rfc6020Mapping.DEFAULT, Rfc6020Mapping.DESCRIPTION, Rfc6020Mapping.REFERENCE, Rfc6020Mapping.CONFIG,
Rfc6020Mapping.MANDATORY, Rfc6020Mapping.MUST, Rfc6020Mapping.PRESENCE, Rfc6020Mapping.MIN_ELEMENTS,
Rfc6020Mapping.MAX_ELEMENTS);
public static final Map<StatementDefinition, Set<StatementDefinition>> SUPPORTED_REFINE_TARGETS;
static {
final Builder<StatementDefinition, Set<StatementDefinition>> b = ImmutableMap.builder();
- b.put(Rfc6020Mapping.DEFAULT, ImmutableSet.<StatementDefinition>of(Rfc6020Mapping.LEAF, Rfc6020Mapping.CHOICE));
- b.put(Rfc6020Mapping.MANDATORY, ImmutableSet.<StatementDefinition>of(
+ b.put(Rfc6020Mapping.DEFAULT, ImmutableSet.of(Rfc6020Mapping.LEAF, Rfc6020Mapping.CHOICE));
+ b.put(Rfc6020Mapping.MANDATORY, ImmutableSet.of(
Rfc6020Mapping.LEAF, Rfc6020Mapping.CHOICE, Rfc6020Mapping.ANYXML));
- b.put(Rfc6020Mapping.PRESENCE, ImmutableSet.<StatementDefinition>of(Rfc6020Mapping.CONTAINER));
- b.put(Rfc6020Mapping.MUST, ImmutableSet.<StatementDefinition>of(
+ b.put(Rfc6020Mapping.PRESENCE, ImmutableSet.of(Rfc6020Mapping.CONTAINER));
+ b.put(Rfc6020Mapping.MUST, ImmutableSet.of(
Rfc6020Mapping.CONTAINER, Rfc6020Mapping.LIST, Rfc6020Mapping.LEAF,
Rfc6020Mapping.LEAF_LIST, Rfc6020Mapping.ANYXML));
- b.put(Rfc6020Mapping.MIN_ELEMENTS, ImmutableSet.<StatementDefinition>of(
+ b.put(Rfc6020Mapping.MIN_ELEMENTS, ImmutableSet.of(
Rfc6020Mapping.LIST, Rfc6020Mapping.LEAF_LIST));
- b.put(Rfc6020Mapping.MAX_ELEMENTS, ImmutableSet.<StatementDefinition>of(
+ b.put(Rfc6020Mapping.MAX_ELEMENTS, ImmutableSet.of(
Rfc6020Mapping.LIST, Rfc6020Mapping.LEAF_LIST));
SUPPORTED_REFINE_TARGETS = b.build();
}
- public static final Set<StatementDefinition> SUPPORTED_AUGMENT_TARGETS = ImmutableSet.<StatementDefinition>of(
+ public static final Set<StatementDefinition> SUPPORTED_AUGMENT_TARGETS = ImmutableSet.of(
Rfc6020Mapping.CONTAINER, Rfc6020Mapping.LIST, Rfc6020Mapping.CASE, Rfc6020Mapping.INPUT, Rfc6020Mapping.OUTPUT,
Rfc6020Mapping.NOTIFICATION, Rfc6020Mapping.CHOICE, Rfc6020Mapping.RPC);
- public static final Set<StatementDefinition> SUPPORTED_CASE_SHORTHANDS = ImmutableSet.<StatementDefinition>of(
+ public static final Set<StatementDefinition> SUPPORTED_CASE_SHORTHANDS = ImmutableSet.of(
Rfc6020Mapping.CONTAINER, Rfc6020Mapping.LIST, Rfc6020Mapping.LEAF, Rfc6020Mapping.LEAF_LIST,
Rfc6020Mapping.ANYXML);
- public static final Set<StatementDefinition> SUPPORTED_DATA_NODES = ImmutableSet.<StatementDefinition>of(
+ public static final Set<StatementDefinition> SUPPORTED_DATA_NODES = ImmutableSet.of(
Rfc6020Mapping.CONTAINER, Rfc6020Mapping.LIST, Rfc6020Mapping.LEAF, Rfc6020Mapping.LEAF_LIST,
Rfc6020Mapping.ANYXML);
}
@Override
public Set<Module> findModuleByNamespace(final URI namespace) {
final Set<Module> ret = getNamespaceToModules().get(namespace);
- return ret == null ? Collections.<Module> emptySet() : ret;
+ return ret == null ? Collections.emptySet() : ret;
}
@Override
this.modules = ImmutableSet.copyOf(sortedModuleList);
final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(
- new TreeMap<URI, Collection<Module>>(), MODULE_SET_SUPPLIER);
+ new TreeMap<>(), MODULE_SET_SUPPLIER);
final SetMultimap<String, Module> nameMap = Multimaps.newSetMultimap(
- new TreeMap<String, Collection<Module>>(), MODULE_SET_SUPPLIER);
+ new TreeMap<>(), MODULE_SET_SUPPLIER);
Set<ModuleIdentifier> modIdBuilder = new HashSet<>();
for (Module m : modulesInit) {
nameMap.put(m.getName(), m);
* Invest some quality time in building up lookup tables for both.
*/
final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(
- new TreeMap<URI, Collection<Module>>(), MODULE_SET_SUPPLIER);
+ new TreeMap<>(), MODULE_SET_SUPPLIER);
final SetMultimap<String, Module> nameMap = Multimaps.newSetMultimap(
- new TreeMap<String, Collection<Module>>(), MODULE_SET_SUPPLIER);
+ new TreeMap<>(), MODULE_SET_SUPPLIER);
Set<ModuleIdentifier> modIdBuilder = new HashSet<>();
for (Module m : modules) {
super(ctx);
// initDerivedIdentities
- Set<IdentitySchemaNode> derivedIdentitiesInit = new HashSet<IdentitySchemaNode>();
+ Set<IdentitySchemaNode> derivedIdentitiesInit = new HashSet<>();
List<StmtContext<?, ?, ?>> derivedIdentitiesCtxList = ctx.getFromNamespace(
DerivedIdentitiesNamespace.class, ctx.getStatementArgument());
if (derivedIdentitiesCtxList == null) {
@Deprecated
public static List<ModuleBuilder> sort(final Collection<ModuleBuilder> builders) {
List<TopologicalSort.Node> sorted = sortInternal(ModuleOrModuleBuilder.fromAll(
- Collections.<Module>emptySet(),builders));
+ Collections.emptySet(),builders));
return Lists.transform(sorted, NODE_TO_MODULEBUILDER);
}
*/
public static List<Module> sort(final Module... modules) {
List<TopologicalSort.Node> sorted = sortInternal(ModuleOrModuleBuilder.fromAll(asList(modules),
- Collections.<ModuleBuilder>emptyList()));
+ Collections.emptyList()));
// Cast to Module from Node and return
return Lists.transform(sorted, TOPOLOGY_FUNCTION);
}
}
if (moduleGraph.get(name) == null) {
- moduleGraph.put(name, Maps.<Date, ModuleNodeImpl> newHashMap());
+ moduleGraph.put(name, Maps.newHashMap());
}
if (moduleGraph.get(name).get(rev) != null) {
@Test
public void testFindIdentity() {
- assertNull(BuilderUtils.findIdentity(Collections.<IdentitySchemaNodeBuilder>emptySet(), "test-identity"));
+ assertNull(BuilderUtils.findIdentity(Collections.emptySet(), "test-identity"));
}
@Test
@Test
public void testIdentifierMatching() {
- List<String> ids = new ArrayList<String>();
+ List<String> ids = new ArrayList<>();
// valid
ids.add("_ok98-.87.-.8...88-asdAD");
ids.add("AA.bcd");
File dependenciesDir = new File(getClass().getResource("/sorting-test").toURI());
YangContextParser parser = new YangParserImpl();
modules = parser.parseFile(yangFile, dependenciesDir).getModules();
- SchemaContext ctx = new SchemaContextImpl(modules, Collections.<ModuleIdentifier, String> emptyMap());
+ SchemaContext ctx = new SchemaContextImpl(modules, Collections.emptyMap());
checkOrder(modules);
assertSetEquals(modules, ctx.getModules());
}
Set<Module> newModules = parser.parseFiles(testFiles).getModules();
assertSetEquals(newModules, modules);
- ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String> emptyMap());
+ ctx = new SchemaContextImpl(newModules, Collections.emptyMap());
assertSetEquals(newModules, ctx.getModules());
// ##########
newModules = parser.parseFiles(testFiles, null).getModules();
assertSetEquals(newModules, modules);
- ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String> emptyMap());
+ ctx = new SchemaContextImpl(newModules, Collections.emptyMap());
assertSetEquals(newModules, ctx.getModules());
// ##########
List<InputStream> streams = new ArrayList<>();
}
newModules = parser.parseSources(BuilderUtils.filesToByteSources(testFiles)).getModules();
assertSetEquals(newModules, modules);
- ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String> emptyMap());
+ ctx = new SchemaContextImpl(newModules, Collections.emptyMap());
assertSetEquals(newModules, ctx.getModules());
// ##########
streams.clear();
}
newModules = parser.parseSources(BuilderUtils.filesToByteSources(testFiles), null).getModules();
assertSetEquals(newModules, modules);
- ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String> emptyMap());
+ ctx = new SchemaContextImpl(newModules, Collections.emptyMap());
assertSetEquals(newModules, ctx.getModules());
}
File yangSubmodul = new File(getClass().getResource("/yang-grammar-test/submodule-header-extension.yang")
.toURI());
- List<File> yangs = new ArrayList<File>();
+ List<File> yangs = new ArrayList<>();
yangs.add(yangModul);
yangs.add(yangSubmodul);
File yangModule2 = new File(getClass().getResource("/yang-grammar-test/stmtsep-in-statements2.yang").toURI());
File yangSubModule = new File(getClass().getResource("/yang-grammar-test/stmtsep-in-statements-sub.yang").toURI());
- List<File> yangs = new ArrayList<File>();
+ List<File> yangs = new ArrayList<>();
yangs.add(yangModule1);
yangs.add(yangModule2);
yangs.add(yangSubModule);
repository.registerSchemaSource(new SchemaSourceProvider<YangTextSchemaSource>() {
@Override
public CheckedFuture<YangTextSchemaSource, SchemaSourceException> getSource(final SourceIdentifier sourceIdentifier) {
- return Futures.<YangTextSchemaSource, SchemaSourceException>immediateCheckedFuture(source1);
+ return Futures.immediateCheckedFuture(source1);
}
}, PotentialSchemaSource.create(s1, YangTextSchemaSource.class, 1));
repository.registerSchemaSource(new SchemaSourceProvider<YangTextSchemaSource>() {
@Override
public CheckedFuture<YangTextSchemaSource, SchemaSourceException> getSource(final SourceIdentifier sourceIdentifier) {
- return Futures.<YangTextSchemaSource, SchemaSourceException>immediateCheckedFuture(source2);
+ return Futures.immediateCheckedFuture(source2);
}
}, PotentialSchemaSource.create(s2, YangTextSchemaSource.class, 1));
}
}
};
assertThat(Collections2.transform(listener.registeredSources, potSourceToSID),
- both(hasItem(new SourceIdentifier("test", Optional.<String>absent())))
+ both(hasItem(new SourceIdentifier("test", Optional.absent())))
.and(hasItem(new SourceIdentifier("test", Optional.of("2012-12-12"))))
.and(hasItem(new SourceIdentifier("test", Optional.of("2013-12-12"))))
.and(hasItem(new SourceIdentifier("module", Optional.of("2010-12-12"))))
sharedSchemaRepository.registerSchemaSource(new SchemaSourceProvider<YangTextSchemaSource>() {
@Override
public CheckedFuture<YangTextSchemaSource, SchemaSourceException> getSource(final SourceIdentifier sourceIdentifier) {
- return Futures.<YangTextSchemaSource, SchemaSourceException>immediateCheckedFuture(new YangTextSchemaSource(runningId) {
+ return Futures.immediateCheckedFuture(new YangTextSchemaSource(runningId) {
@Override
protected MoreObjects.ToStringHelper addToStringAttributes(final MoreObjects.ToStringHelper toStringHelper) {
return toStringHelper;
List<ModuleBuilder> l = ModuleDependencySort.sort(builders);
assertDependencyGraph(ModuleDependencySort.createModuleGraph(ModuleOrModuleBuilder.fromAll(
- Collections.<Module>emptySet(), Arrays.asList(builders))));
+ Collections.emptySet(), Arrays.asList(builders))));
Matcher<String> cOrD = anyOf(equalTo(c.getName()), equalTo(d.getName()));