/** * Creates an immutable graph based on the specified connections. Duplicate * connections are not allowed and will cause this method to fail. * @param connections The connections to use for creating a graph. * @return A new instance of an immutable graph. */ public static <E extends ConnectionData> ImmutableGraph<E> copyOf( Iterable<? extends Connection<? extends E>> connections) { return new ImmutableGraph<>(connections); }
/** * Creates an immutable graph based on the specified connections. Duplicate * connections are not allowed and will cause this method to fail. * @param connections The connections to use for creating a graph. * @return A new instance of an immutable graph. */ public static <E extends ConnectionData> ImmutableGraph<E> copyOf( Iterable<? extends Connection<? extends E>> connections) { return new ImmutableGraph<>(connections); }
/** * Creates an immutable copy of the specified {@link Graph}. This method * recognizes when the supplied graph is an instance of {@link ImmutableGraph} * , and will avoid making a copy in this case. * @param graph A graph. * @param <E> The type of connection data. * @return An immutable copy of the graph. */ @SuppressWarnings("unchecked") public static <E extends ConnectionData> ImmutableGraph<E> copyOf( Graph<? extends E> graph) { if (graph instanceof ImmutableGraph) { return (ImmutableGraph<E>) graph; } return new ImmutableGraph<>(graph.getConnections()); }
/** * Creates an immutable copy of the specified {@link Graph}. This method * recognizes when the supplied graph is an instance of {@link ImmutableGraph} * , and will avoid making a copy in this case. * @param graph A graph. * @param <E> The type of connection data. * @return An immutable copy of the graph. */ @SuppressWarnings("unchecked") public static <E extends ConnectionData> ImmutableGraph<E> copyOf( Graph<? extends E> graph) { if (graph instanceof ImmutableGraph) { return (ImmutableGraph<E>) graph; } return new ImmutableGraph<>(graph.getConnections()); }