code stringlengths 23 201k | docstring stringlengths 17 96.2k | func_name stringlengths 0 235 | language stringclasses 1
value | repo stringlengths 8 72 | path stringlengths 11 317 | url stringlengths 57 377 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
@SuppressWarnings("unchecked")
protected static final <K, V> ImmutableMap<K, V> mapOf(K k0, V v0, Object... rest) {
Preconditions.checkArgument(rest.length % 2 == 0, "Uneven args: %s", rest.length);
ImmutableMap.Builder<K, V> builder = new ImmutableMap.Builder<>();
builder.put(k0, v0);
for (int i = 0... | Expects the current {@link ExpectFailure} failure message to NOT match the provided regex,
using {@code Pattern.DOTALL} to match newlines. | mapOf | java | google/truth | extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java | https://github.com/google/truth/blob/master/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java | Apache-2.0 |
@SuppressWarnings("unchecked")
protected static final <K, V> ImmutableMultimap<K, V> multimapOf(K k0, V v0, Object... rest) {
Preconditions.checkArgument(rest.length % 2 == 0, "Uneven args: %s", rest.length);
ImmutableMultimap.Builder<K, V> builder = new ImmutableMultimap.Builder<>();
builder.put(k0, v0)... | Expects the current {@link ExpectFailure} failure message to NOT match the provided regex,
using {@code Pattern.DOTALL} to match newlines. | multimapOf | java | google/truth | extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java | https://github.com/google/truth/blob/master/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java | Apache-2.0 |
final void checkMethodNamesEndWithForValues(
Class<?> clazz, Class<? extends Subject> pseudoSuperclass) {
// Don't run this test twice.
if (!testIsRunOnce()) {
return;
}
Set<String> diff = Sets.difference(getMethodNames(clazz), getMethodNames(pseudoSuperclass));
assertWithMessage("Found... | Expects the current {@link ExpectFailure} failure message to NOT match the provided regex,
using {@code Pattern.DOTALL} to match newlines. | checkMethodNamesEndWithForValues | java | google/truth | extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java | https://github.com/google/truth/blob/master/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java | Apache-2.0 |
private static ImmutableSet<String> getMethodNames(Class<?> clazz) {
ImmutableSet.Builder<String> names = ImmutableSet.builder();
for (Method method : clazz.getMethods()) {
names.add(method.getName());
}
return names.build();
} | Expects the current {@link ExpectFailure} failure message to NOT match the provided regex,
using {@code Pattern.DOTALL} to match newlines. | getMethodNames | java | google/truth | extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java | https://github.com/google/truth/blob/master/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java | Apache-2.0 |
public static Subject.Factory<Re2jStringSubject, String> re2jString() {
return Re2jStringSubject::new;
} | Returns a subject factory for {@link String} subjects which you can use to assert things about
{@link com.google.re2j.Pattern} regexes.
<p>This subject does not replace Truth's built-in {@link com.google.common.truth.StringSubject}
but instead provides only the methods needed to deal with regular expressions.
@see co... | re2jString | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
@Override
protected String actualCustomStringRepresentation() {
return quote(checkNotNull(actual));
} | Subject for {@link String} subjects which you can use to assert things about {@link
com.google.re2j.Pattern} regexes.
@see #re2jString | actualCustomStringRepresentation | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
public void matches(String regex) {
if (!Pattern.matches(regex, checkNotNull(actual))) {
failWithActual("expected to match ", regex);
}
} | Fails if the string does not match the given regex. | matches | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
@GwtIncompatible("com.google.re2j.Pattern")
public void matches(Pattern regex) {
if (!regex.matcher(checkNotNull(actual)).matches()) {
failWithActual("expected to match ", regex);
}
} | Fails if the string does not match the given regex. | matches | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
public void doesNotMatch(String regex) {
if (Pattern.matches(regex, checkNotNull(actual))) {
failWithActual("expected to fail to match", regex);
}
} | Fails if the string matches the given regex. | doesNotMatch | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
@GwtIncompatible("com.google.re2j.Pattern")
public void doesNotMatch(Pattern regex) {
if (regex.matcher(checkNotNull(actual)).matches()) {
failWithActual("expected to fail to match", regex);
}
} | Fails if the string matches the given regex. | doesNotMatch | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
@GwtIncompatible("com.google.re2j.Pattern")
public void containsMatch(Pattern pattern) {
if (!pattern.matcher(checkNotNull(actual)).find()) {
failWithActual("expected to contain a match for", pattern);
}
} | Fails if the string does not contain a match on the given regex. | containsMatch | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
public void containsMatch(String regex) {
if (!doContainsMatch(checkNotNull(actual), regex)) {
failWithActual("expected to contain a match for", regex);
}
} | Fails if the string does not contain a match on the given regex. | containsMatch | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
@GwtIncompatible("com.google.re2j.Pattern")
public void doesNotContainMatch(Pattern pattern) {
if (pattern.matcher(checkNotNull(actual)).find()) {
failWithActual("expected not to contain a match for", pattern);
}
} | Fails if the string contains a match on the given regex. | doesNotContainMatch | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
public void doesNotContainMatch(String regex) {
if (doContainsMatch(checkNotNull(actual), regex)) {
failWithActual("expected not to contain a match for", regex);
}
} | Fails if the string contains a match on the given regex. | doesNotContainMatch | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
private static String quote(CharSequence toBeWrapped) {
return "\"" + toBeWrapped + "\"";
} | Fails if the string contains a match on the given regex. | quote | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
private static boolean doContainsMatch(String subject, String regex) {
return Pattern.compile(regex).matcher(subject).find();
} | Fails if the string contains a match on the given regex. | doContainsMatch | java | google/truth | extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | https://github.com/google/truth/blob/master/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java | Apache-2.0 |
@Override
public Description matchClass(ClassTree tree, VisitorState state) {
if (!isCorrespondence(tree.getExtendsClause(), state)) {
return NO_MATCH;
}
List<CorrespondenceCode> replacements = computePossibleReplacements(tree, state);
Tree parent = state.getPath().getParentPath().getLeaf();
... | Refactors some subclasses of {@code Correspondence} to instead call {@code Correspondence.from}.
The exact change generated for a given correspondence depends on the details of how it is defined
and used. | matchClass | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static void replaceTypeReferences(
SuggestedFix.Builder fix, Set<Tree> typeReferences, String newType) {
for (Tree reference : typeReferences) {
fix.replace(reference, newType);
}
} | Refactors some subclasses of {@code Correspondence} to instead call {@code Correspondence.from}.
The exact change generated for a given correspondence depends on the details of how it is defined
and used. | replaceTypeReferences | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private String visibilityModifierOnConstructor(ClassTree tree) {
MethodTree constructor =
tree.getMembers().stream()
.filter(t -> t instanceof MethodTree)
.map(t -> (MethodTree) t)
.filter(t -> t.getName().contentEquals("<init>"))
.findAny()
.get()... | Refactors some subclasses of {@code Correspondence} to instead call {@code Correspondence.from}.
The exact change generated for a given correspondence depends on the details of how it is defined
and used. | visibilityModifierOnConstructor | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static SetMultimap<ParentType, NewClassTree> findCalls(
Symbol classSymbol, VisitorState state) {
SetMultimap<ParentType, NewClassTree> calls = HashMultimap.create();
new TreeScanner<Void, Void>() {
private ParentType parentType = ParentType.OTHER;
@Override
public @Nullable Voi... | Returns all calls to the constructor for the given {@code classSymbol}, organized by {@linkplain ParentType whether they happen inside a call to {@code comparingElementsUsing}. | findCalls | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
@Override
public @Nullable Void visitMethodInvocation(MethodInvocationTree node, Void unused) {
boolean isComparingElementsUsing =
Optional.of(node.getMethodSelect())
.filter(t -> t.getKind() == MEMBER_SELECT)
.map(t -> (MemberSelectTree) t)
.fil... | Returns all calls to the constructor for the given {@code classSymbol}, organized by {@linkplain ParentType whether they happen inside a call to {@code comparingElementsUsing}. | visitMethodInvocation | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
@Override
public @Nullable Void visitNewClass(NewClassTree node, Void unused) {
if (getSymbol(node.getIdentifier()).equals(classSymbol)) {
calls.put(parentType, node);
}
return super.visitNewClass(node, unused);
} | Returns all calls to the constructor for the given {@code classSymbol}, organized by {@linkplain ParentType whether they happen inside a call to {@code comparingElementsUsing}. | visitNewClass | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static Set<Tree> findTypeReferences(Symbol classSymbol, VisitorState state) {
Set<Tree> references = new HashSet<>();
new TreeScanner<Void, Void>() {
@Override
public @Nullable Void scan(Tree node, Void unused) {
if (Objects.equals(getSymbol(node), classSymbol)
&& getDecl... | Finds all references to the name of the given type, excluding (a) when the name is defined
(e.g, {@code public class MyCorrespondence}) and (b) calls to its constructor (e.g., {@code new
MyCorrespondence()}). The goal is to find every reference that we aren't already modifying so
that we can rewrite, e.g., fields of th... | findTypeReferences | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
@Override
public @Nullable Void scan(Tree node, Void unused) {
if (Objects.equals(getSymbol(node), classSymbol)
&& getDeclaredSymbol(node) == null // Don't touch the ClassTree that we're replacing.
) {
references.add(node);
}
return super.scan(node, unused);
... | Finds all references to the name of the given type, excluding (a) when the name is defined
(e.g, {@code public class MyCorrespondence}) and (b) calls to its constructor (e.g., {@code new
MyCorrespondence()}). The goal is to find every reference that we aren't already modifying so
that we can rewrite, e.g., fields of th... | scan | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
@Override
public @Nullable Void visitNewClass(NewClassTree node, Void aVoid) {
scan(node.getEnclosingExpression(), null);
// Do NOT scan node.getIdentifier().
scan(node.getTypeArguments(), null);
scan(node.getArguments(), null);
scan(node.getClassBody(), null);
retu... | Finds all references to the name of the given type, excluding (a) when the name is defined
(e.g, {@code public class MyCorrespondence}) and (b) calls to its constructor (e.g., {@code new
MyCorrespondence()}). The goal is to find every reference that we aren't already modifying so
that we can rewrite, e.g., fields of th... | visitNewClass | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static ImmutableList<CorrespondenceCode> computePossibleReplacements(
ClassTree classTree, VisitorState state) {
ImmutableSetMultimap<MemberType, Tree> members =
classTree.getMembers().stream()
.collect(toImmutableSetMultimap(m -> MemberType.from(m, state), m -> m));
if (member... | If the given correspondence implementation is "simple enough," returns one or more possible
replacements for its definition and instantiation sites. | computePossibleReplacements | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static ImmutableList<BinaryPredicateCode> makeBinaryPredicates(
ClassTree classTree, MethodTree compareMethod, VisitorState state) {
Tree comparison = maybeMakeLambdaBody(compareMethod, state);
if (comparison == null) {
ClassTree enclosing = findStrictlyEnclosing(state, ClassTree.class);
... | Returns one or more possible replacements for the given correspondence's {@code compare} method's definition and for code to pass to {@code Correspondence.from) to construct a correspondence that uses the replacement. | makeBinaryPredicates | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static @Nullable Tree maybeMakeLambdaBody(MethodTree compareMethod, VisitorState state) {
ExpressionTree comparison = returnExpression(compareMethod);
if (comparison != null) {
// compare() is defined as simply `return something;`. Create a lambda.
return comparison;
}
/*
* com... | Converts the given method into a lambda, either expression or block, if "appropriate." For
details about the various cases, see implementation comments. | maybeMakeLambdaBody | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
@Override
public @Nullable Void scan(Tree node, Void aVoid) {
if (paramsOfEnclosingMethod.contains(getSymbol(node))) {
referenceFound[0] = true;
}
return super.scan(node, aVoid);
} | Converts the given method into a lambda, either expression or block, if "appropriate." For
details about the various cases, see implementation comments. | scan | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static <T extends Tree> @Nullable T findStrictlyEnclosing(
VisitorState state, Class<T> clazz) {
return stream(state.getPath().getParentPath())
.filter(clazz::isInstance)
.map(clazz::cast)
.findAny()
.orElse(null);
} | Like {@link VisitorState#findEnclosing} but doesn't consider the leaf to enclose itself. | findStrictlyEnclosing | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static @Nullable Tree findChildOfStrictlyEnclosing(
VisitorState state, Class<? extends Tree> clazz) {
Tree previous = state.getPath().getLeaf();
for (Tree t : state.getPath().getParentPath()) {
if (clazz.isInstance(t)) {
return previous;
}
previous = t;
}
return ... | Like {@link #findStrictlyEnclosing} but returns not the found element but its child along the
path. For example, if called with {@code ClassTree}, it might return a {@code MethodTree}
inside the class. | findChildOfStrictlyEnclosing | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
static CorrespondenceCode create(BinaryPredicateCode binaryPredicate, String description) {
return new AutoValue_CorrespondenceSubclassToFactoryCall_CorrespondenceCode(
binaryPredicate, description);
} | A {@code Correspondence.from} call to replace the instantiation site of a {@code
Correspondence}. Often the call is self-contained (if it's a lambda), but sometimes it's a
method reference, in which case it's accompanied by a separate method definition. | create | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
final String callSite() {
return format("Correspondence.from(%s, %s)", binaryPredicate().usage(), description());
} | A {@code Correspondence.from} call to replace the instantiation site of a {@code
Correspondence}. Often the call is self-contained (if it's a lambda), but sometimes it's a
method reference, in which case it's accompanied by a separate method definition. | callSite | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
final String supportingMethodDefinition() {
return binaryPredicate().supportingMethodDefinition().orElse("");
} | A {@code Correspondence.from} call to replace the instantiation site of a {@code
Correspondence}. Often the call is self-contained (if it's a lambda), but sometimes it's a
method reference, in which case it's accompanied by a separate method definition. | supportingMethodDefinition | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
static BinaryPredicateCode fromParamsAndExpression(
CharSequence param0, CharSequence param1, String expression) {
return create(String.format("(%s, %s) -> %s", param0, param1, expression), null);
} | Code that can be inserted as the first argument of a {@code Correspondence.from} call. Often
it's a lambda, but sometimes it's a method reference, in which case it's accompanied by a
separate method definition. | fromParamsAndExpression | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
static BinaryPredicateCode create(String usage, @Nullable String supportingMethodDefinition) {
return new AutoValue_CorrespondenceSubclassToFactoryCall_BinaryPredicateCode(
usage, Optional.ofNullable(supportingMethodDefinition));
} | Code that can be inserted as the first argument of a {@code Correspondence.from} call. Often
it's a lambda, but sometimes it's a method reference, in which case it's accompanied by a
separate method definition. | create | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static @Nullable ExpressionTree returnExpression(MethodTree method) {
List<? extends StatementTree> statements = method.getBody().getStatements();
if (statements.size() != 1) {
return null;
}
StatementTree statement = getOnlyElement(statements);
if (statement.getKind() != RETURN) {
... | Code that can be inserted as the first argument of a {@code Correspondence.from} call. Often
it's a lambda, but sometimes it's a method reference, in which case it's accompanied by a
separate method definition. | returnExpression | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static boolean constructorCallsOnlySuper(MethodTree constructor) {
List<? extends StatementTree> statements = constructor.getBody().getStatements();
if (statements.size() != 1) {
return false;
}
StatementTree statement = getOnlyElement(statements);
if (statement.getKind() != EXPRESSION... | Code that can be inserted as the first argument of a {@code Correspondence.from} call. Often
it's a lambda, but sometimes it's a method reference, in which case it's accompanied by a
separate method definition. | constructorCallsOnlySuper | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
static MemberType from(Tree tree, VisitorState state) {
Symbol symbol = getDeclaredSymbol(tree);
if (!(symbol instanceof MethodSymbol)) {
return OTHER;
}
MethodSymbol methodSymbol = (MethodSymbol) symbol;
if (methodSymbol.getSimpleName().contentEquals("<init>")) {
return C... | Whether a member is of one of the standard {@link Correspondence} methods that we know how to
migrate and, if so, which one. | from | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static boolean overrides(
MethodSymbol potentialOverrider, String clazz, String method, VisitorState state) {
Symbol overridable =
getEnclosedElements(state.getTypeFromString(clazz).tsym).stream()
.filter(s -> s.getKind() == METHOD)
.filter(m -> m.getSimpleName().conten... | Whether a member is of one of the standard {@link Correspondence} methods that we know how to
migrate and, if so, which one. | overrides | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
private static boolean isCorrespondence(Tree supertypeTree, VisitorState state) {
Type correspondenceType = COM_GOOGLE_COMMON_TRUTH_CORRESPONDENCE.get(state);
if (correspondenceType == null) {
return false;
}
return supertypeTree != null
&& state.getTypes().isSameType(getSymbol(supertypeTr... | Whether a member is of one of the standard {@link Correspondence} methods that we know how to
migrate and, if so, which one. | isCorrespondence | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java | Apache-2.0 |
@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
if (!ONE_ARG_FAIL.matches(tree, state) && !TWO_ARG_FAIL.matches(tree, state)) {
return NO_MATCH;
}
SuggestedFix.Builder fix = SuggestedFix.builder();
if (tree.getMethodSelect().getKind() == IDENT... | Migrates Truth subjects from the old {@code fail(String, Object)} to the new {@code
failWithActual(String, Object)}, tweaking verbs for the new grammar. For example:
<pre>{@code
// Before:
fail("has foo", expected);
// After:
failWithActual("expected to have foo", expected);
}</pre> | matchMethodInvocation | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/FailWithFacts.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/FailWithFacts.java | Apache-2.0 |
private static @Nullable String newVerb(String oldVerb) {
List<String> old = Splitter.on(whitespace()).splitToList(oldVerb);
String first = old.get(0);
if (CAPITAL_LETTER.matchesAnyOf(first)) {
// "hasFoo," etc. TODO(cpovirk): Handle these.
return null;
}
if (first.equals("does") && old.... | Migrates Truth subjects from the old {@code fail(String, Object)} to the new {@code
failWithActual(String, Object)}, tweaking verbs for the new grammar. For example:
<pre>{@code
// Before:
fail("has foo", expected);
// After:
failWithActual("expected to have foo", expected);
}</pre> | newVerb | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/FailWithFacts.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/FailWithFacts.java | Apache-2.0 |
private static String skip(List<String> old, int i) {
return old.stream().skip(i).collect(joining(" "));
} | Migrates Truth subjects from the old {@code fail(String, Object)} to the new {@code
failWithActual(String, Object)}, tweaking verbs for the new grammar. For example:
<pre>{@code
// Before:
fail("has foo", expected);
// After:
failWithActual("expected to have foo", expected);
}</pre> | skip | java | google/truth | refactorings/src/main/java/com/google/common/truth/refactorings/FailWithFacts.java | https://github.com/google/truth/blob/master/refactorings/src/main/java/com/google/common/truth/refactorings/FailWithFacts.java | Apache-2.0 |
@Before
public void setUp() {
compilationHelper =
CompilationTestHelper.newInstance(CorrespondenceSubclassToFactoryCall.class, getClass());
refactoringHelper =
BugCheckerRefactoringTestHelper.newInstance(
CorrespondenceSubclassToFactoryCall.class, getClass());
} | @author cpovirk@google.com (Chris Povirk) | setUp | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | Apache-2.0 |
@Test
public void testPositiveCase() {
compilationHelper
.addSourceFile("testdata/CorrespondenceSubclassToFactoryCallPositiveCases.java")
.doTest();
} | @author cpovirk@google.com (Chris Povirk) | testPositiveCase | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | Apache-2.0 |
@Test
public void testPositiveCase2() {
compilationHelper
.addSourceFile("testdata/CorrespondenceSubclassToFactoryCallPositiveCases2.java")
.doTest();
} | @author cpovirk@google.com (Chris Povirk) | testPositiveCase2 | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | Apache-2.0 |
@Test
public void testNegativeCase() {
compilationHelper
.addSourceFile("testdata/CorrespondenceSubclassToFactoryCallNegativeCases.java")
.doTest();
} | @author cpovirk@google.com (Chris Povirk) | testNegativeCase | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | Apache-2.0 |
@Test
public void refactoring() {
refactoringHelper
.addInput("testdata/CorrespondenceSubclassToFactoryCallPositiveCases.java")
.addOutput("testdata/CorrespondenceSubclassToFactoryCallPositiveCases_expected.java")
.doTest();
} | @author cpovirk@google.com (Chris Povirk) | refactoring | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | Apache-2.0 |
@Test
public void refactoring2() {
refactoringHelper
.addInput("testdata/CorrespondenceSubclassToFactoryCallPositiveCases2.java")
.addOutput("testdata/CorrespondenceSubclassToFactoryCallPositiveCases2_expected.java")
.doTest();
} | @author cpovirk@google.com (Chris Povirk) | refactoring2 | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCallTest.java | Apache-2.0 |
@Test
public void testPositiveCase() {
compilationHelper.addSourceFile("testdata/FailWithFactsPositiveCases.java").doTest();
} | @author cpovirk@google.com (Chris Povirk) | testPositiveCase | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/FailWithFactsTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/FailWithFactsTest.java | Apache-2.0 |
@Before
public void setUp() {
compilationHelper = CompilationTestHelper.newInstance(NamedToWithMessage.class, getClass());
} | @author cpovirk@google.com (Chris Povirk) | setUp | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/NamedToWithMessageTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/NamedToWithMessageTest.java | Apache-2.0 |
@Test
public void testPositiveCase() {
compilationHelper.addSourceFile("NamedToWithMessagePositiveCases.java").doTest();
} | @author cpovirk@google.com (Chris Povirk) | testPositiveCase | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/NamedToWithMessageTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/NamedToWithMessageTest.java | Apache-2.0 |
@Test
public void testNegativeCase() {
compilationHelper.addSourceFile("NamedToWithMessageNegativeCases.java").doTest();
} | @author cpovirk@google.com (Chris Povirk) | testNegativeCase | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/NamedToWithMessageTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/NamedToWithMessageTest.java | Apache-2.0 |
@Before
public void setUp() {
compilationHelper =
CompilationTestHelper.newInstance(StoreActualValueInField.class, getClass());
refactoringHelper =
BugCheckerRefactoringTestHelper.newInstance(new StoreActualValueInField(), getClass());
} | @author cpovirk@google.com (Chris Povirk) | setUp | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/StoreActualValueInFieldTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/StoreActualValueInFieldTest.java | Apache-2.0 |
@Test
public void testPositiveCase() {
compilationHelper.addSourceFile("StoreActualValueInFieldPositiveCases.java").doTest();
} | @author cpovirk@google.com (Chris Povirk) | testPositiveCase | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/StoreActualValueInFieldTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/StoreActualValueInFieldTest.java | Apache-2.0 |
@Test
public void testNegativeCase() {
compilationHelper.addSourceFile("StoreActualValueInFieldNegativeCases.java").doTest();
} | @author cpovirk@google.com (Chris Povirk) | testNegativeCase | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/StoreActualValueInFieldTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/StoreActualValueInFieldTest.java | Apache-2.0 |
@Test
public void refactoring() {
refactoringHelper
.addInput("StoreActualValueInFieldPositiveCases.java")
.addOutput("StoreActualValueInFieldPositiveCases_expected.java")
.doTest();
} | @author cpovirk@google.com (Chris Povirk) | refactoring | java | google/truth | refactorings/src/test/java/com/google/common/truth/refactorings/StoreActualValueInFieldTest.java | https://github.com/google/truth/blob/master/refactorings/src/test/java/com/google/common/truth/refactorings/StoreActualValueInFieldTest.java | Apache-2.0 |
public static <V, E> DirectedAcyclicGraph<V, E> from(DirectedGraph<V, E> graph) {
if (Graphs.stronglyConnectedComponents(graph, false).size() > 0) {
throw new CycleException();
}
Set<V> top = new Set<>(graph.vertexHash(), graph.vertexEquality()).linear();
Set<V> bottom = new Set<>(graph.vertexHas... | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | from | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
public Set<V> top() {
return top;
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | top | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
public Set<V> bottom() {
return bottom;
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | bottom | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
public DirectedGraph<V, E> directedGraph() {
return graph.clone();
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | directedGraph | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> add(IEdge<V, E> edge) {
return link(edge.from(), edge.to(), edge.value());
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | add | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> remove(IEdge<V, E> edge) {
return unlink(edge.from(), edge.to());
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | remove | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> link(V from, V to, E edge) {
return link(from, to, edge, (BinaryOperator<E>) MERGE_LAST_WRITE_WINS);
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | link | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> link(V from, V to) {
return link(from, to, null, (BinaryOperator<E>) MERGE_LAST_WRITE_WINS);
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | link | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public Set<V> vertices() {
return graph.vertices();
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | vertices | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public Iterable<IEdge<V, E>> edges() {
return graph.edges();
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | edges | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public E edge(V src, V dst) {
return graph.edge(src, dst);
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | edge | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public E edge(V src, V dst, E notFound) {
return graph.edge(src, dst, notFound);
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | edge | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public Set<V> in(V vertex) {
return graph.in(vertex);
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | in | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public Set<V> out(V vertex) {
return graph.out(vertex);
} | @return a directed acyclic graph equivalent to {@code graph}
@throws CycleException if {@code graph} contains a cycle | out | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> link(V from, V to, E edge, BinaryOperator<E> merge) {
boolean
newFrom = !vertices().contains(from),
newTo = !vertices().contains(to);
if (!newFrom && !newTo && !out(from).contains(to) && createsCycle(from, to)) {
throw new CycleException();
... | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | link | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> unlink(V from, V to) {
DirectedGraph<V, E> graphPrime = graph.unlink(from, to);
Set<V> topPrime = graph.in(to).size() == 1 ? top.add(to) : top;
Set<V> bottomPrime = graph.out(from).size() == 1 ? bottom.add(from) : bottom;
if (isLinear() || graph == graphPr... | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | unlink | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> merge(IGraph<V, E> graph, BinaryOperator<E> merge) {
return from(this.graph.merge(graph, merge));
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | merge | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> select(ISet<V> vertices) {
return from(graph.select(vertices));
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | select | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> add(V vertex) {
if (graph.vertices().contains(vertex)) {
return this;
} else {
DirectedGraph<V, E> graphPrime = graph.add(vertex);
Set<V> topPrime = top.add(vertex);
Set<V> bottomPrime = bottom.add(vertex);
if (isLinear()) {
g... | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | add | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> remove(V vertex) {
if (graph.vertices().contains(vertex)) {
Set<V> topPrime =
top.union(graph.out(vertex).stream().filter(v -> graph.in(v).size() == 1).collect(Sets.collector()));
Set<V> bottomPrime =
bottom.union(graph.in(vertex).stream(... | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | remove | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> forked() {
return graph.isLinear() ? new DirectedAcyclicGraph<>(graph.forked(), top.forked(), bottom.forked()) : this;
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | forked | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> linear() {
return graph.isLinear() ? this : new DirectedAcyclicGraph<>(graph.linear(), top.linear(), bottom.linear());
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | linear | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public boolean isLinear() {
return graph.isLinear();
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | isLinear | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public boolean isDirected() {
return true;
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | isDirected | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public <U> DirectedAcyclicGraph<V, U> mapEdges(Function<IEdge<V, E>, U> f) {
return new DirectedAcyclicGraph<>(graph.mapEdges(f), top, bottom);
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | mapEdges | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> transpose() {
return new DirectedAcyclicGraph<>(graph.transpose(), bottom, top);
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | transpose | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public ToLongFunction<V> vertexHash() {
return graph.vertexHash();
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | vertexHash | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public BiPredicate<V, V> vertexEquality() {
return graph.vertexEquality();
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | vertexEquality | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public int hashCode() {
return graph.hashCode();
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | hashCode | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public boolean equals(Object obj) {
return graph.equals(obj);
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | equals | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public String toString() {
return graph.toString();
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | toString | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
@Override
public DirectedAcyclicGraph<V, E> clone() {
return new DirectedAcyclicGraph<V, E>(graph.clone(), bottom.clone(), top.clone());
} | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | clone | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
private boolean createsCycle(V from, V to) {
Iterator<V> upstreamIterator = Graphs.bfsVertices(LinearList.of(from), this::in).iterator();
Iterator<V> downstreamIterator = Graphs.bfsVertices(LinearList.of(to), this::out).iterator();
if (!upstreamIterator.hasNext() || !downstreamIterator.hasNext()) {
r... | @param from the source of the edge
@param to the destination of the edge
@param edge the value of the edge
@param merge the merge function for the edge values, if an edge already exists
@return a graph containing the new edge
@throws CycleException if the new edge creates a cycle | createsCycle | java | lacuna/bifurcan | src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/DirectedAcyclicGraph.java | MIT |
public static <V> FloatMap<V> from(IMap<Number, V> m) {
if (m instanceof FloatMap) {
return (FloatMap) m.forked();
} else {
return from(m.entries());
}
} | A map which has floating-point keys, built atop {@link IntMap}, with which it shares performance characteristics.
<p>
Since this is intended foremost as a sorted data structure, it does not allow {@code NaN} and treats {@code -0.0} as
equivalent to {@code 0.0}. Anyone looking for identity-based semantics should use a ... | from | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public static <V> FloatMap<V> from(java.util.Map<Number, V> m) {
return from(m.entrySet());
} | @param m a Java map
@return a forked copy of the map | from | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public static <V> FloatMap<V> from(Collection<java.util.Map.Entry<Number, V>> collection) {
FloatMap<V> map = new FloatMap<V>().linear();
for (java.util.Map.Entry<Number, V> entry : collection) {
map = map.put(entry.getKey().doubleValue(), entry.getValue());
}
return map.forked();
} | @param collection a collection of {@link java.util.Map.Entry} objects
@return an {@link IntMap} representing the entries in the collection | from | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public static <V> FloatMap<V> from(IList<IEntry<Number, V>> list) {
FloatMap<V> map = new FloatMap<V>().linear();
for (IEntry<Number, V> entry : list) {
map = map.put(entry.key().doubleValue(), entry.value());
}
return map.forked();
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | from | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public Comparator<Double> comparator() {
return Comparator.naturalOrder();
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | comparator | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public ToLongFunction<Double> keyHash() {
return HASH;
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | keyHash | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public BiPredicate<Double, Double> keyEquality() {
return Double::equals;
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | keyEquality | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public boolean contains(double key) {
return map.contains(doubleToLong(key));
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | contains | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public IList<IEntry<Double, V>> entries() {
return Lists.lazyMap(map.entries(), FloatMap::convertEntry);
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | entries | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.