target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test public void testTokenOverlapMixed() { String[] tokens1 = {"the", "cat", "has", "a", "brown", "bag"}; String[] tokens2 = {"bag", "dog", "was", "cat", "blah", "bag"}; assertEquals(2, StringUtils.tokenOverlap(tokens1, tokens2)); } | public static int tokenOverlap(String[] tokens1, String[] tokens2) { Set<String> tokenSet2 = new HashSet<String>(Arrays.asList(tokens2)); int score = 0; for (String word : tokens1) if (tokenSet2.contains(word)) score++; return score; } | StringUtils { public static int tokenOverlap(String[] tokens1, String[] tokens2) { Set<String> tokenSet2 = new HashSet<String>(Arrays.asList(tokens2)); int score = 0; for (String word : tokens1) if (tokenSet2.contains(word)) score++; return score; } } | StringUtils { public static int tokenOverlap(String[] tokens1, String[] tokens2) { Set<String> tokenSet2 = new HashSet<String>(Arrays.asList(tokens2)); int score = 0; for (String word : tokens1) if (tokenSet2.contains(word)) score++; return score; } } | StringUtils { public static int tokenOverlap(String[] tokens1, String[] tokens2) { Set<String> tokenSet2 = new HashSet<String>(Arrays.asList(tokens2)); int score = 0; for (String word : tokens1) if (tokenSet2.contains(word)) score++; return score; } static int tokenOverlap(String[] tokens1, String[] tokens2); static i... | StringUtils { public static int tokenOverlap(String[] tokens1, String[] tokens2) { Set<String> tokenSet2 = new HashSet<String>(Arrays.asList(tokens2)); int score = 0; for (String word : tokens1) if (tokenSet2.contains(word)) score++; return score; } static int tokenOverlap(String[] tokens1, String[] tokens2); static i... |
@Test public void testSentenceText() { Sentence sent = new Sentence(2, 10, 8); String text = "abcdefghijlkmop"; sent.setText(text); assertEquals(text.substring(2, 10), sent.sentenceText()); } | public String sentenceText() { return (text == null) ? null : text.substring(start, end); } | Sentence implements Serializable, Iterable<Annotation> { public String sentenceText() { return (text == null) ? null : text.substring(start, end); } } | Sentence implements Serializable, Iterable<Annotation> { public String sentenceText() { return (text == null) ? null : text.substring(start, end); } private Sentence(); Sentence(int start, int end, int numTokens); } | Sentence implements Serializable, Iterable<Annotation> { public String sentenceText() { return (text == null) ? null : text.substring(start, end); } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation annotation); ... | Sentence implements Serializable, Iterable<Annotation> { public String sentenceText() { return (text == null) ? null : text.substring(start, end); } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation annotation); ... |
@Test public void testEmptyGet() { Sentence sent = new Sentence(0, 100, 1); assertEquals(null, sent.getAnnotation(0)); } | public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } } | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } private Sentence(); Sentence(int start, int end, int numTokens); } | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation annotation); Annotation ge... | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation annotation); Annotation ge... |
@Test (expected=IndexOutOfBoundsException.class) public void testNegativeSet() { Sentence sent = new Sentence(0, 100, 1); Annotation annot = new SimpleAnnotation("blah"); sent.addAnnotation(-1, annot); } | public void addAnnotation(int index, Annotation annotation) { tokenAnnotations[index] = annotation; } | Sentence implements Serializable, Iterable<Annotation> { public void addAnnotation(int index, Annotation annotation) { tokenAnnotations[index] = annotation; } } | Sentence implements Serializable, Iterable<Annotation> { public void addAnnotation(int index, Annotation annotation) { tokenAnnotations[index] = annotation; } private Sentence(); Sentence(int start, int end, int numTokens); } | Sentence implements Serializable, Iterable<Annotation> { public void addAnnotation(int index, Annotation annotation) { tokenAnnotations[index] = annotation; } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation ann... | Sentence implements Serializable, Iterable<Annotation> { public void addAnnotation(int index, Annotation annotation) { tokenAnnotations[index] = annotation; } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation ann... |
@Test (expected=IndexOutOfBoundsException.class) public void testTooLargeSet() { Sentence sent = new Sentence(0, 100, 1); Annotation annot = new SimpleAnnotation("blah"); sent.addAnnotation(1, annot); } | public void addAnnotation(int index, Annotation annotation) { tokenAnnotations[index] = annotation; } | Sentence implements Serializable, Iterable<Annotation> { public void addAnnotation(int index, Annotation annotation) { tokenAnnotations[index] = annotation; } } | Sentence implements Serializable, Iterable<Annotation> { public void addAnnotation(int index, Annotation annotation) { tokenAnnotations[index] = annotation; } private Sentence(); Sentence(int start, int end, int numTokens); } | Sentence implements Serializable, Iterable<Annotation> { public void addAnnotation(int index, Annotation annotation) { tokenAnnotations[index] = annotation; } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation ann... | Sentence implements Serializable, Iterable<Annotation> { public void addAnnotation(int index, Annotation annotation) { tokenAnnotations[index] = annotation; } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation ann... |
@Test (expected=IndexOutOfBoundsException.class) public void testNegativeGet() { Sentence sent = new Sentence(0, 100, 1); sent.getAnnotation(-1); } | public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } } | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } private Sentence(); Sentence(int start, int end, int numTokens); } | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation annotation); Annotation ge... | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation annotation); Annotation ge... |
@Test (expected=IndexOutOfBoundsException.class) public void testTooLargeGet() { Sentence sent = new Sentence(0, 100, 1); sent.getAnnotation(1); } | public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } } | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } private Sentence(); Sentence(int start, int end, int numTokens); } | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation annotation); Annotation ge... | Sentence implements Serializable, Iterable<Annotation> { public Annotation getAnnotation(int index) { return tokenAnnotations[index]; } private Sentence(); Sentence(int start, int end, int numTokens); void setText(String text); String sentenceText(); void addAnnotation(int index, Annotation annotation); Annotation ge... |
@Test public void testDependencyParseTree() { Sentence sentence = new Sentence(0, 100, 7); for (int i = 0; i < TEST_PARSED_SENTENCES.length; ++i) sentence.addAnnotation( i, annotationFromCoNLL(TEST_PARSED_SENTENCES[i])); DependencyTreeNode[] tree = sentence.dependencyParseTree(); assertEquals(TEST_PARSED_SENTENCES.leng... | public DependencyTreeNode[] dependencyParseTree() { if (tokenAnnotations.length == 0 || !tokenAnnotations[0].hasDependencyParent()) return new DependencyTreeNode[0]; SimpleDependencyTreeNode[] nodes = new SimpleDependencyTreeNode[tokenAnnotations.length]; for (int i = 0; i < nodes.length; ++i) nodes[i] = new SimpleDepe... | Sentence implements Serializable, Iterable<Annotation> { public DependencyTreeNode[] dependencyParseTree() { if (tokenAnnotations.length == 0 || !tokenAnnotations[0].hasDependencyParent()) return new DependencyTreeNode[0]; SimpleDependencyTreeNode[] nodes = new SimpleDependencyTreeNode[tokenAnnotations.length]; for (in... | Sentence implements Serializable, Iterable<Annotation> { public DependencyTreeNode[] dependencyParseTree() { if (tokenAnnotations.length == 0 || !tokenAnnotations[0].hasDependencyParent()) return new DependencyTreeNode[0]; SimpleDependencyTreeNode[] nodes = new SimpleDependencyTreeNode[tokenAnnotations.length]; for (in... | Sentence implements Serializable, Iterable<Annotation> { public DependencyTreeNode[] dependencyParseTree() { if (tokenAnnotations.length == 0 || !tokenAnnotations[0].hasDependencyParent()) return new DependencyTreeNode[0]; SimpleDependencyTreeNode[] nodes = new SimpleDependencyTreeNode[tokenAnnotations.length]; for (in... | Sentence implements Serializable, Iterable<Annotation> { public DependencyTreeNode[] dependencyParseTree() { if (tokenAnnotations.length == 0 || !tokenAnnotations[0].hasDependencyParent()) return new DependencyTreeNode[0]; SimpleDependencyTreeNode[] nodes = new SimpleDependencyTreeNode[tokenAnnotations.length]; for (in... |
@Test public void testTaggedTokens() { Sentence sentence = makeSentence(0, 4, TOKEN_INFO, RANGES); StringPair[] taggedPairs = sentence.taggedTokens(); assertEquals(TOKEN_INFO.length, taggedPairs.length); for (int i = 0; i < TOKEN_INFO.length; ++i) { assertEquals(TOKEN_INFO[i][0], taggedPairs[i].x); assertEquals(TOKEN_I... | public StringPair[] taggedTokens() { StringPair[] taggedTokens = new StringPair[tokenAnnotations.length]; for (int i = 0; i < taggedTokens.length; ++i) taggedTokens[i] = new StringPair( tokenAnnotations[i].word(), tokenAnnotations[i].pos()); return taggedTokens; } | Sentence implements Serializable, Iterable<Annotation> { public StringPair[] taggedTokens() { StringPair[] taggedTokens = new StringPair[tokenAnnotations.length]; for (int i = 0; i < taggedTokens.length; ++i) taggedTokens[i] = new StringPair( tokenAnnotations[i].word(), tokenAnnotations[i].pos()); return taggedTokens; ... | Sentence implements Serializable, Iterable<Annotation> { public StringPair[] taggedTokens() { StringPair[] taggedTokens = new StringPair[tokenAnnotations.length]; for (int i = 0; i < taggedTokens.length; ++i) taggedTokens[i] = new StringPair( tokenAnnotations[i].word(), tokenAnnotations[i].pos()); return taggedTokens; ... | Sentence implements Serializable, Iterable<Annotation> { public StringPair[] taggedTokens() { StringPair[] taggedTokens = new StringPair[tokenAnnotations.length]; for (int i = 0; i < taggedTokens.length; ++i) taggedTokens[i] = new StringPair( tokenAnnotations[i].word(), tokenAnnotations[i].pos()); return taggedTokens; ... | Sentence implements Serializable, Iterable<Annotation> { public StringPair[] taggedTokens() { StringPair[] taggedTokens = new StringPair[tokenAnnotations.length]; for (int i = 0; i < taggedTokens.length; ++i) taggedTokens[i] = new StringPair( tokenAnnotations[i].word(), tokenAnnotations[i].pos()); return taggedTokens; ... |
@Test public void testInitialAgreement() { double[][] v1 = new double[][] { {1, 1, 0, 0, 1, 0}, {0, 0, 1, 0, 1, 0}, {0, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 0, 0}, {1, 0, 1, 0, 0, 1}, {1, 1, 0, 0, 1, 1}, }; double[][] v2 = new double[][] { {1, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 1, 0}, {0, 1, 1, 0, 0, 1}, {0, 1, 1, 1, 1, 0}, {1, 0, 1... | public double computeInitialAgreement() { return computeKappaScore( info1.edges, info2.edges, numNodes); } | NetworkConfluency { public double computeInitialAgreement() { return computeKappaScore( info1.edges, info2.edges, numNodes); } } | NetworkConfluency { public double computeInitialAgreement() { return computeKappaScore( info1.edges, info2.edges, numNodes); } NetworkConfluency(String matrixFile1,
String matrixFile2,
Format format); NetworkConfluency(SparseMatrix matrix1, SparseMatrix matrix... | NetworkConfluency { public double computeInitialAgreement() { return computeKappaScore( info1.edges, info2.edges, numNodes); } NetworkConfluency(String matrixFile1,
String matrixFile2,
Format format); NetworkConfluency(SparseMatrix matrix1, SparseMatrix matrix... | NetworkConfluency { public double computeInitialAgreement() { return computeKappaScore( info1.edges, info2.edges, numNodes); } NetworkConfluency(String matrixFile1,
String matrixFile2,
Format format); NetworkConfluency(SparseMatrix matrix1, SparseMatrix matrix... |
@Test public void testConstructor() { Synset synset = new BaseSynset(PartsOfSpeech.NOUN); assertEquals(PartsOfSpeech.NOUN, synset.getPartOfSpeech()); } | public PartsOfSpeech getPartOfSpeech() { return pos; } | BaseSynset implements Synset { public PartsOfSpeech getPartOfSpeech() { return pos; } } | BaseSynset implements Synset { public PartsOfSpeech getPartOfSpeech() { return pos; } BaseSynset(String synsetName); BaseSynset(int offset, PartsOfSpeech pos); BaseSynset(PartsOfSpeech pos); } | BaseSynset implements Synset { public PartsOfSpeech getPartOfSpeech() { return pos; } BaseSynset(String synsetName); BaseSynset(int offset, PartsOfSpeech pos); BaseSynset(PartsOfSpeech pos); void addMorphyMapping(String original, String lemma); int getSenseNumber(); void setSenseNumber(int senseNumber); String getNam... | BaseSynset implements Synset { public PartsOfSpeech getPartOfSpeech() { return pos; } BaseSynset(String synsetName); BaseSynset(int offset, PartsOfSpeech pos); BaseSynset(PartsOfSpeech pos); void addMorphyMapping(String original, String lemma); int getSenseNumber(); void setSenseNumber(int senseNumber); String getNam... |
@Test public void testTokenOverlapExpNoSequence() { String[] tokens1 = {"the", "cat", "has", "a", "brown", "bag"}; String[] tokens2 = {"bag", "dog", "was", "cat", "blah", "bag"}; assertEquals(3, StringUtils.tokenOverlapExp(tokens1, tokens2)); } | public static int tokenOverlapExp(String[] tokens1, String[] tokens2) { int index1 = 0; int index2 = 0; int score = 0; for (int i = 0; i < tokens1.length; ++i) for (int j = 0; j < tokens2.length; ++j) if (tokens1[i].equals(tokens2[j])) score += Math.pow(findOverlap(tokens1, i, tokens2, j), 2); return score; } | StringUtils { public static int tokenOverlapExp(String[] tokens1, String[] tokens2) { int index1 = 0; int index2 = 0; int score = 0; for (int i = 0; i < tokens1.length; ++i) for (int j = 0; j < tokens2.length; ++j) if (tokens1[i].equals(tokens2[j])) score += Math.pow(findOverlap(tokens1, i, tokens2, j), 2); return scor... | StringUtils { public static int tokenOverlapExp(String[] tokens1, String[] tokens2) { int index1 = 0; int index2 = 0; int score = 0; for (int i = 0; i < tokens1.length; ++i) for (int j = 0; j < tokens2.length; ++j) if (tokens1[i].equals(tokens2[j])) score += Math.pow(findOverlap(tokens1, i, tokens2, j), 2); return scor... | StringUtils { public static int tokenOverlapExp(String[] tokens1, String[] tokens2) { int index1 = 0; int index2 = 0; int score = 0; for (int i = 0; i < tokens1.length; ++i) for (int j = 0; j < tokens2.length; ++j) if (tokens1[i].equals(tokens2[j])) score += Math.pow(findOverlap(tokens1, i, tokens2, j), 2); return scor... | StringUtils { public static int tokenOverlapExp(String[] tokens1, String[] tokens2) { int index1 = 0; int index2 = 0; int score = 0; for (int i = 0; i < tokens1.length; ++i) for (int j = 0; j < tokens2.length; ++j) if (tokens1[i].equals(tokens2[j])) score += Math.pow(findOverlap(tokens1, i, tokens2, j), 2); return scor... |
@Test (expected=IllegalArgumentException.class) public void testMergeBadPos() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.VERB); s1.merge(s2); } | public void merge(Synset synset) { if (pos != synset.getPartOfSpeech()) throw new IllegalArgumentException( "Cannot merge synsets with different parts of speech."); Set<Duple<String, Synset>> toRemove = new HashSet<Duple<String, Synset>>(); for (String relation : getKnownRelationTypes()) { Set<Synset> links = relations... | BaseSynset implements Synset { public void merge(Synset synset) { if (pos != synset.getPartOfSpeech()) throw new IllegalArgumentException( "Cannot merge synsets with different parts of speech."); Set<Duple<String, Synset>> toRemove = new HashSet<Duple<String, Synset>>(); for (String relation : getKnownRelationTypes()) ... | BaseSynset implements Synset { public void merge(Synset synset) { if (pos != synset.getPartOfSpeech()) throw new IllegalArgumentException( "Cannot merge synsets with different parts of speech."); Set<Duple<String, Synset>> toRemove = new HashSet<Duple<String, Synset>>(); for (String relation : getKnownRelationTypes()) ... | BaseSynset implements Synset { public void merge(Synset synset) { if (pos != synset.getPartOfSpeech()) throw new IllegalArgumentException( "Cannot merge synsets with different parts of speech."); Set<Duple<String, Synset>> toRemove = new HashSet<Duple<String, Synset>>(); for (String relation : getKnownRelationTypes()) ... | BaseSynset implements Synset { public void merge(Synset synset) { if (pos != synset.getPartOfSpeech()) throw new IllegalArgumentException( "Cannot merge synsets with different parts of speech."); Set<Duple<String, Synset>> toRemove = new HashSet<Duple<String, Synset>>(); for (String relation : getKnownRelationTypes()) ... |
@Test public void testNoSubsumer() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); SynsetSimilarity sim = new ResnickSimilarity(null); assertEquals(0, sim.similarity(s1, s2), .00001); } | public double similarity(Synset synset1, Synset synset2) { List<Synset> subsumers = SynsetRelations.lowestCommonHypernyms( synset1, synset2); if (subsumers.size() == 0) return 0; double bestIC = 0; for (Synset subsumer : subsumers) bestIC = Math.max(bestIC, ic.informationContent(subsumer)); return bestIC; } | ResnickSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { List<Synset> subsumers = SynsetRelations.lowestCommonHypernyms( synset1, synset2); if (subsumers.size() == 0) return 0; double bestIC = 0; for (Synset subsumer : subsumers) bestIC = Math.max(bestIC, ic.information... | ResnickSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { List<Synset> subsumers = SynsetRelations.lowestCommonHypernyms( synset1, synset2); if (subsumers.size() == 0) return 0; double bestIC = 0; for (Synset subsumer : subsumers) bestIC = Math.max(bestIC, ic.information... | ResnickSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { List<Synset> subsumers = SynsetRelations.lowestCommonHypernyms( synset1, synset2); if (subsumers.size() == 0) return 0; double bestIC = 0; for (Synset subsumer : subsumers) bestIC = Math.max(bestIC, ic.information... | ResnickSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { List<Synset> subsumers = SynsetRelations.lowestCommonHypernyms( synset1, synset2); if (subsumers.size() == 0) return 0; double bestIC = 0; for (Synset subsumer : subsumers) bestIC = Math.max(bestIC, ic.information... |
@Test public void testSimilarity() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); MockIC ic = new MockIC(); Synset worst = new BaseSynset(PartsOfSpeech.NOUN); s1.addRelation(Relation.HYPERNYM, worst); s2.addRelation(Relation.HYPERNYM, worst); Synset best = new BaseSyns... | public double similarity(Synset synset1, Synset synset2) { List<Synset> subsumers = SynsetRelations.lowestCommonHypernyms( synset1, synset2); if (subsumers.size() == 0) return 0; double bestIC = 0; for (Synset subsumer : subsumers) bestIC = Math.max(bestIC, ic.informationContent(subsumer)); return bestIC; } | ResnickSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { List<Synset> subsumers = SynsetRelations.lowestCommonHypernyms( synset1, synset2); if (subsumers.size() == 0) return 0; double bestIC = 0; for (Synset subsumer : subsumers) bestIC = Math.max(bestIC, ic.information... | ResnickSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { List<Synset> subsumers = SynsetRelations.lowestCommonHypernyms( synset1, synset2); if (subsumers.size() == 0) return 0; double bestIC = 0; for (Synset subsumer : subsumers) bestIC = Math.max(bestIC, ic.information... | ResnickSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { List<Synset> subsumers = SynsetRelations.lowestCommonHypernyms( synset1, synset2); if (subsumers.size() == 0) return 0; double bestIC = 0; for (Synset subsumer : subsumers) bestIC = Math.max(bestIC, ic.information... | ResnickSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { List<Synset> subsumers = SynsetRelations.lowestCommonHypernyms( synset1, synset2); if (subsumers.size() == 0) return 0; double bestIC = 0; for (Synset subsumer : subsumers) bestIC = Math.max(bestIC, ic.information... |
@Test public void testLeskSimilarity() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); s1.setDefinition("how now brown cow"); s2.setDefinition("how now sad meow"); SynsetSimilarity sim = new LeskSimilarity(); assertEquals(2, sim.similarity(s1, s2), .00001); } | public double similarity(Synset synset1, Synset synset2) { String[] gloss1 = synset1.getGloss().split("\\s+"); String[] gloss2 = synset2.getGloss().split("\\s+"); return StringUtils.tokenOverlap(gloss1, gloss2); } | LeskSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { String[] gloss1 = synset1.getGloss().split("\\s+"); String[] gloss2 = synset2.getGloss().split("\\s+"); return StringUtils.tokenOverlap(gloss1, gloss2); } } | LeskSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { String[] gloss1 = synset1.getGloss().split("\\s+"); String[] gloss2 = synset2.getGloss().split("\\s+"); return StringUtils.tokenOverlap(gloss1, gloss2); } } | LeskSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { String[] gloss1 = synset1.getGloss().split("\\s+"); String[] gloss2 = synset2.getGloss().split("\\s+"); return StringUtils.tokenOverlap(gloss1, gloss2); } double similarity(Synset synset1, Synset synset2); } | LeskSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { String[] gloss1 = synset1.getGloss().split("\\s+"); String[] gloss2 = synset2.getGloss().split("\\s+"); return StringUtils.tokenOverlap(gloss1, gloss2); } double similarity(Synset synset1, Synset synset2); } |
@Test public void testNoSubsumer() { MockIC ic = new MockIC(); Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); SynsetSimilarity sim = new LinSimilarity(ic); assertEquals(0, sim.similarity(s1, s2), .00001); } | public double similarity(Synset synset1, Synset synset2) { double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); return (2d * icSubsumer) / (ic1 + ic2); } | LinSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); return (2d * icSubsumer) / (ic1 ... | LinSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); return (2d * icSubsumer) / (ic1 ... | LinSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); return (2d * icSubsumer) / (ic1 ... | LinSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); return (2d * icSubsumer) / (ic1 ... |
@Test public void testSimilarity() { MockIC ic = new MockIC(); Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); ic.ic.put(s1, 2.0); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); ic.ic.put(s2, 3.0); Synset worst = new BaseSynset(PartsOfSpeech.NOUN); s1.addRelation(Relation.HYPERNYM, worst); s2.addRelation(Relation.HYPE... | public double similarity(Synset synset1, Synset synset2) { double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); return (2d * icSubsumer) / (ic1 + ic2); } | LinSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); return (2d * icSubsumer) / (ic1 ... | LinSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); return (2d * icSubsumer) / (ic1 ... | LinSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); return (2d * icSubsumer) / (ic1 ... | LinSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); return (2d * icSubsumer) / (ic1 ... |
@Test public void testNoSubsumer() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); SynsetSimilarity sim = new WuPalmerSimilarity(); assertEquals(0, sim.similarity(s1, s2), .00001); } | public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++; double distance1 = SynsetRelations.shortestPathD... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... |
@Test public void testNounSimilarity() { Synset subsumer = new BaseSynset(PartsOfSpeech.NOUN); Synset parent = subsumer; for (int i = 0; i < 4; ++i) { Synset child = new BaseSynset(PartsOfSpeech.NOUN); child.addRelation(Relation.HYPERNYM, parent); parent = child; } Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); s1.add... | public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++; double distance1 = SynsetRelations.shortestPathD... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... |
@Test public void testVerbSimilarity() { Synset subsumer = new BaseSynset(PartsOfSpeech.VERB); Synset parent = subsumer; for (int i = 0; i < 4; ++i) { Synset child = new BaseSynset(PartsOfSpeech.NOUN); child.addRelation(Relation.HYPERNYM, parent); parent = child; } Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); s1.add... | public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++; double distance1 = SynsetRelations.shortestPathD... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... | WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... |
@Test public void testNoSubsumer() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); SynsetSimilarity sim = new JiangConrathSimilarity(null); assertEquals(Double.MAX_VALUE, sim.similarity(s1, s1), .00001); } | public double similarity(Synset synset1, Synset synset2) { if (synset1.equals(synset2)) return Double.MAX_VALUE; double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); double difference = ic... | JiangConrathSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.equals(synset2)) return Double.MAX_VALUE; double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim... | JiangConrathSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.equals(synset2)) return Double.MAX_VALUE; double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim... | JiangConrathSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.equals(synset2)) return Double.MAX_VALUE; double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim... | JiangConrathSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.equals(synset2)) return Double.MAX_VALUE; double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim... |
@Test public void testTokenOverlapExpBoundedSequence() { String[] tokens1 = {"the", "cat", "has", "chicken", "bag", "the"}; String[] tokens2 = {"the", "dog", "was", "blarg", "chicken", "bag"}; assertEquals(7, StringUtils.tokenOverlapExp(tokens1, tokens2)); } | public static int tokenOverlapExp(String[] tokens1, String[] tokens2) { int index1 = 0; int index2 = 0; int score = 0; for (int i = 0; i < tokens1.length; ++i) for (int j = 0; j < tokens2.length; ++j) if (tokens1[i].equals(tokens2[j])) score += Math.pow(findOverlap(tokens1, i, tokens2, j), 2); return score; } | StringUtils { public static int tokenOverlapExp(String[] tokens1, String[] tokens2) { int index1 = 0; int index2 = 0; int score = 0; for (int i = 0; i < tokens1.length; ++i) for (int j = 0; j < tokens2.length; ++j) if (tokens1[i].equals(tokens2[j])) score += Math.pow(findOverlap(tokens1, i, tokens2, j), 2); return scor... | StringUtils { public static int tokenOverlapExp(String[] tokens1, String[] tokens2) { int index1 = 0; int index2 = 0; int score = 0; for (int i = 0; i < tokens1.length; ++i) for (int j = 0; j < tokens2.length; ++j) if (tokens1[i].equals(tokens2[j])) score += Math.pow(findOverlap(tokens1, i, tokens2, j), 2); return scor... | StringUtils { public static int tokenOverlapExp(String[] tokens1, String[] tokens2) { int index1 = 0; int index2 = 0; int score = 0; for (int i = 0; i < tokens1.length; ++i) for (int j = 0; j < tokens2.length; ++j) if (tokens1[i].equals(tokens2[j])) score += Math.pow(findOverlap(tokens1, i, tokens2, j), 2); return scor... | StringUtils { public static int tokenOverlapExp(String[] tokens1, String[] tokens2) { int index1 = 0; int index2 = 0; int score = 0; for (int i = 0; i < tokens1.length; ++i) for (int j = 0; j < tokens2.length; ++j) if (tokens1[i].equals(tokens2[j])) score += Math.pow(findOverlap(tokens1, i, tokens2, j), 2); return scor... |
@Test public void testSimilarity() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); MockIC ic = new MockIC(); ic.ic.put(s1, 10.0); ic.ic.put(s2, 11.0); Synset worst = new BaseSynset(PartsOfSpeech.NOUN); s1.addRelation(Relation.HYPERNYM, worst); s2.addRelation(Relation.HY... | public double similarity(Synset synset1, Synset synset2) { if (synset1.equals(synset2)) return Double.MAX_VALUE; double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); double difference = ic... | JiangConrathSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.equals(synset2)) return Double.MAX_VALUE; double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim... | JiangConrathSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.equals(synset2)) return Double.MAX_VALUE; double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim... | JiangConrathSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.equals(synset2)) return Double.MAX_VALUE; double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim... | JiangConrathSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.equals(synset2)) return Double.MAX_VALUE; double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim... |
@Test public void testWrongPos() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.VERB); SynsetSimilarity sim = new LeacockChodorowSimilarity(null); assertEquals(0, sim.similarity(s1, s2), .0001); } | public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); return (distance >= 0 && distance <= Integer.MAX_VALUE) ?... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... |
@Test public void testSimilarity() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); addParents(s1, s2); MockReader reader = new MockReader(); SynsetSimilarity sim = new LeacockChodorowSimilarity(reader); double expected = -1 * Math.log(7 / (2d * 1)); assertEquals(expecte... | public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); return (distance >= 0 && distance <= Integer.MAX_VALUE) ?... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... |
@Test public void testSimilarityVerb() { Synset s1 = new BaseSynset(PartsOfSpeech.VERB); Synset s2 = new BaseSynset(PartsOfSpeech.VERB); addParents(s1, s2); MockReader reader = new MockReader(); SynsetSimilarity sim = new LeacockChodorowSimilarity(reader); double expected = -1 * Math.log(7 / (2d * 2)); assertEquals(exp... | public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); return (distance >= 0 && distance <= Integer.MAX_VALUE) ?... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... | LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... |
@Test public void testWrongPos() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.VERB); MockReader reader = new MockReader(); SynsetSimilarity sim = new LeacockChodorowScaledSimilarity(reader); assertEquals(0, sim.similarity(s1, s2), .0001); } | public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } } | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } Lea... | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } Lea... | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } Lea... |
@Test public void testSimilarity() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); addParents(s1, s2); MockReader reader = new MockReader(); SynsetSimilarity sim = new LeacockChodorowScaledSimilarity(reader); double max = -1 * Math.log(1/(2d*1)); double expected = -1 * ... | public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } } | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } Lea... | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } Lea... | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } Lea... |
@Test public void testSimilarityVerb() { Synset s1 = new BaseSynset(PartsOfSpeech.VERB); Synset s2 = new BaseSynset(PartsOfSpeech.VERB); addParents(s1, s2); MockReader reader = new MockReader(); SynsetSimilarity sim = new LeacockChodorowScaledSimilarity(reader); double max = -1 * Math.log(1/(2d*2)); double expected = -... | public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } } | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } Lea... | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } Lea... | LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } Lea... |
@Test public void testLeskSimilarity() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); Synset p2 = new BaseSynset(PartsOfSpeech.NOUN); s1.setDefinition("how now brown cow"); s2.setDefinition("how now sad meow"); p2.setDefinition("cow sad sad"); s2.addRelation(Relation.H... | public double similarity(Synset synset1, Synset synset2) { Set<Synset> synsets1 = Sets.newHashSet(synset1.allRelations()); synsets1.add(synset1); Set<Synset> synsets2 = Sets.newHashSet(synset2.allRelations()); synsets2.add(synset2); double score = 0; for (Synset s1 : synsets1) for (Synset s2 : synsets2) score += score(... | ExtendedLeskSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Set<Synset> synsets1 = Sets.newHashSet(synset1.allRelations()); synsets1.add(synset1); Set<Synset> synsets2 = Sets.newHashSet(synset2.allRelations()); synsets2.add(synset2); double score = 0; for (Synset s1 :... | ExtendedLeskSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Set<Synset> synsets1 = Sets.newHashSet(synset1.allRelations()); synsets1.add(synset1); Set<Synset> synsets2 = Sets.newHashSet(synset2.allRelations()); synsets2.add(synset2); double score = 0; for (Synset s1 :... | ExtendedLeskSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Set<Synset> synsets1 = Sets.newHashSet(synset1.allRelations()); synsets1.add(synset1); Set<Synset> synsets2 = Sets.newHashSet(synset2.allRelations()); synsets2.add(synset2); double score = 0; for (Synset s1 :... | ExtendedLeskSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Set<Synset> synsets1 = Sets.newHashSet(synset1.allRelations()); synsets1.add(synset1); Set<Synset> synsets2 = Sets.newHashSet(synset2.allRelations()); synsets2.add(synset2); double score = 0; for (Synset s1 :... |
@Test public void testDisambiguation() { WordSenseDisambiguation wsdAlg = new ExtendedLeskWordSenseDisambiguation(); Sentence sentences = getSentences(TEST_SENTENCE, TEST_POS); wsdAlg.setup(new GenericMockReader(SYNSET_DATA)); Sentence sent = wsdAlg.disambiguate(sentences); Sentence expected = sentences; assertEquals(e... | public void setup(OntologyReader reader) { this.reader = reader; this.sim = new ExtendedLeskSimilarity(); } | ExtendedLeskWordSenseDisambiguation extends LeskWordSenseDisambiguation { public void setup(OntologyReader reader) { this.reader = reader; this.sim = new ExtendedLeskSimilarity(); } } | ExtendedLeskWordSenseDisambiguation extends LeskWordSenseDisambiguation { public void setup(OntologyReader reader) { this.reader = reader; this.sim = new ExtendedLeskSimilarity(); } } | ExtendedLeskWordSenseDisambiguation extends LeskWordSenseDisambiguation { public void setup(OntologyReader reader) { this.reader = reader; this.sim = new ExtendedLeskSimilarity(); } void setup(OntologyReader reader); String toString(); } | ExtendedLeskWordSenseDisambiguation extends LeskWordSenseDisambiguation { public void setup(OntologyReader reader) { this.reader = reader; this.sim = new ExtendedLeskSimilarity(); } void setup(OntologyReader reader); String toString(); } |
@Test public void testDisambiguation() { WordSenseDisambiguation wsdAlg = new LeskWordSenseDisambiguation(); Sentence sentences = getSentences(TEST_SENTENCE, TEST_POS); wsdAlg.setup(new GenericMockReader(SYNSET_DATA)); Sentence sent = wsdAlg.disambiguate(sentences); Sentence expected = sentences; assertEquals(expected.... | public void setup(OntologyReader reader) { this.reader = reader; this.sim = new LeskSimilarity(); } | LeskWordSenseDisambiguation extends SlidingWindowDisambiguation { public void setup(OntologyReader reader) { this.reader = reader; this.sim = new LeskSimilarity(); } } | LeskWordSenseDisambiguation extends SlidingWindowDisambiguation { public void setup(OntologyReader reader) { this.reader = reader; this.sim = new LeskSimilarity(); } } | LeskWordSenseDisambiguation extends SlidingWindowDisambiguation { public void setup(OntologyReader reader) { this.reader = reader; this.sim = new LeskSimilarity(); } void setup(OntologyReader reader); String toString(); } | LeskWordSenseDisambiguation extends SlidingWindowDisambiguation { public void setup(OntologyReader reader) { this.reader = reader; this.sim = new LeskSimilarity(); } void setup(OntologyReader reader); String toString(); } |
@Test public void testCombinedSize() { Set<String> set1 = new HashSet<String>(); for (String s : array1) set1.add(s); Set<String> set2 = new HashSet<String>(); for (String s : array2) set2.add(s); Set<String> combined = new CombinedSet<String>(set1, set2); assertEquals(6, combined.size()); } | public int size() { int size = 0; for (Set<T> set : sets) size += set.size(); return size; } | CombinedSet extends AbstractSet<T> { public int size() { int size = 0; for (Set<T> set : sets) size += set.size(); return size; } } | CombinedSet extends AbstractSet<T> { public int size() { int size = 0; for (Set<T> set : sets) size += set.size(); return size; } CombinedSet(Set<T>...sets); CombinedSet(Collection<Set<T>> setCollection); } | CombinedSet extends AbstractSet<T> { public int size() { int size = 0; for (Set<T> set : sets) size += set.size(); return size; } CombinedSet(Set<T>...sets); CombinedSet(Collection<Set<T>> setCollection); Iterator<T> iterator(); int size(); } | CombinedSet extends AbstractSet<T> { public int size() { int size = 0; for (Set<T> set : sets) size += set.size(); return size; } CombinedSet(Set<T>...sets); CombinedSet(Collection<Set<T>> setCollection); Iterator<T> iterator(); int size(); } |
@Test public void testDisambiguation() { WordSenseDisambiguation wsdAlg = new PersonalizedPageRankWSD(); Sentence sentences = getSentences(TEST_SENTENCE, TEST_POS); LinkedMockReader reader = new LinkedMockReader(SYNSET_DATA); for (String[] synsetLink : SYNSET_LINKS) reader.connectSynsets(synsetLink[0], synsetLink[1], "... | public void setup(OntologyReader wordnet) { this.wordnet = wordnet; synsetMap = Maps.newHashMap(); synsetList = Lists.newArrayList(); for (String lemma : wordnet.wordnetTerms()) { for (Synset synset : wordnet.getSynsets(lemma)) if (!synsetMap.containsKey(synset)) { synsetMap.put(synset, synsetMap.size()); synsetList.ad... | PersonalizedPageRankWSD extends SlidingWindowDisambiguation { public void setup(OntologyReader wordnet) { this.wordnet = wordnet; synsetMap = Maps.newHashMap(); synsetList = Lists.newArrayList(); for (String lemma : wordnet.wordnetTerms()) { for (Synset synset : wordnet.getSynsets(lemma)) if (!synsetMap.containsKey(syn... | PersonalizedPageRankWSD extends SlidingWindowDisambiguation { public void setup(OntologyReader wordnet) { this.wordnet = wordnet; synsetMap = Maps.newHashMap(); synsetList = Lists.newArrayList(); for (String lemma : wordnet.wordnetTerms()) { for (Synset synset : wordnet.getSynsets(lemma)) if (!synsetMap.containsKey(syn... | PersonalizedPageRankWSD extends SlidingWindowDisambiguation { public void setup(OntologyReader wordnet) { this.wordnet = wordnet; synsetMap = Maps.newHashMap(); synsetList = Lists.newArrayList(); for (String lemma : wordnet.wordnetTerms()) { for (Synset synset : wordnet.getSynsets(lemma)) if (!synsetMap.containsKey(syn... | PersonalizedPageRankWSD extends SlidingWindowDisambiguation { public void setup(OntologyReader wordnet) { this.wordnet = wordnet; synsetMap = Maps.newHashMap(); synsetList = Lists.newArrayList(); for (String lemma : wordnet.wordnetTerms()) { for (Synset synset : wordnet.getSynsets(lemma)) if (!synsetMap.containsKey(syn... |
@Test public void testIterator() { Set<String> set1 = new HashSet<String>(); for (String s : array1) set1.add(s); Set<String> set2 = new HashSet<String>(); for (String s : array2) set2.add(s); Set<String> combined = new CombinedSet<String>(set1, set2); Iterator<String> comboIter = combined.iterator(); Iterator<String> ... | public Iterator<T> iterator() { List<Iterator<T>> iters = new ArrayList<Iterator<T>>(); for (Set<T> set : sets) iters.add(set.iterator()); return new CombinedIterator<T>(iters); } | CombinedSet extends AbstractSet<T> { public Iterator<T> iterator() { List<Iterator<T>> iters = new ArrayList<Iterator<T>>(); for (Set<T> set : sets) iters.add(set.iterator()); return new CombinedIterator<T>(iters); } } | CombinedSet extends AbstractSet<T> { public Iterator<T> iterator() { List<Iterator<T>> iters = new ArrayList<Iterator<T>>(); for (Set<T> set : sets) iters.add(set.iterator()); return new CombinedIterator<T>(iters); } CombinedSet(Set<T>...sets); CombinedSet(Collection<Set<T>> setCollection); } | CombinedSet extends AbstractSet<T> { public Iterator<T> iterator() { List<Iterator<T>> iters = new ArrayList<Iterator<T>>(); for (Set<T> set : sets) iters.add(set.iterator()); return new CombinedIterator<T>(iters); } CombinedSet(Set<T>...sets); CombinedSet(Collection<Set<T>> setCollection); Iterator<T> iterator(); int... | CombinedSet extends AbstractSet<T> { public Iterator<T> iterator() { List<Iterator<T>> iters = new ArrayList<Iterator<T>>(); for (Set<T> set : sets) iters.add(set.iterator()); return new CombinedIterator<T>(iters); } CombinedSet(Set<T>...sets); CombinedSet(Collection<Set<T>> setCollection); Iterator<T> iterator(); int... |
@Test public void testPut() { Map<String,String> extendedMap = new ExtendedMap<String, String>(map1); for (Map.Entry<String, String> s : map2.entrySet()) assertNull(extendedMap.put(s.getKey(), s.getValue())); assertEquals(3, map1.size()); } | public V put(K key, V value) { if (baseMap.containsKey(key)) throw new IllegalArgumentException("Should not reinsert keys"); return extendedMap.put(key, value); } | ExtendedMap extends AbstractMap<K, V> { public V put(K key, V value) { if (baseMap.containsKey(key)) throw new IllegalArgumentException("Should not reinsert keys"); return extendedMap.put(key, value); } } | ExtendedMap extends AbstractMap<K, V> { public V put(K key, V value) { if (baseMap.containsKey(key)) throw new IllegalArgumentException("Should not reinsert keys"); return extendedMap.put(key, value); } ExtendedMap(Map<K, V> baseMap); } | ExtendedMap extends AbstractMap<K, V> { public V put(K key, V value) { if (baseMap.containsKey(key)) throw new IllegalArgumentException("Should not reinsert keys"); return extendedMap.put(key, value); } ExtendedMap(Map<K, V> baseMap); Set<Map.Entry<K, V>> entrySet(); V get(Object key); V put(K key, V value); } | ExtendedMap extends AbstractMap<K, V> { public V put(K key, V value) { if (baseMap.containsKey(key)) throw new IllegalArgumentException("Should not reinsert keys"); return extendedMap.put(key, value); } ExtendedMap(Map<K, V> baseMap); Set<Map.Entry<K, V>> entrySet(); V get(Object key); V put(K key, V value); } |
@Test public void testGet() { Map<String,String> extendedMap = new ExtendedMap<String, String>(map1); for (String key : map1.keySet()) assertEquals(map1.get(key), extendedMap.get(key)); for (Map.Entry<String, String> s : map2.entrySet()) extendedMap.put(s.getKey(), s.getValue()); for (String key : map1.keySet()) assert... | public V get(Object key) { V value = baseMap.get(key); return (value != null) ? value : extendedMap.get(key); } | ExtendedMap extends AbstractMap<K, V> { public V get(Object key) { V value = baseMap.get(key); return (value != null) ? value : extendedMap.get(key); } } | ExtendedMap extends AbstractMap<K, V> { public V get(Object key) { V value = baseMap.get(key); return (value != null) ? value : extendedMap.get(key); } ExtendedMap(Map<K, V> baseMap); } | ExtendedMap extends AbstractMap<K, V> { public V get(Object key) { V value = baseMap.get(key); return (value != null) ? value : extendedMap.get(key); } ExtendedMap(Map<K, V> baseMap); Set<Map.Entry<K, V>> entrySet(); V get(Object key); V put(K key, V value); } | ExtendedMap extends AbstractMap<K, V> { public V get(Object key) { V value = baseMap.get(key); return (value != null) ? value : extendedMap.get(key); } ExtendedMap(Map<K, V> baseMap); Set<Map.Entry<K, V>> entrySet(); V get(Object key); V put(K key, V value); } |
@Test public void testCompareToFirstDiffer() { StringPair pair1 = new StringPair("cat", "alpha"); StringPair pair2 = new StringPair("cats", "dog"); assertTrue(pair1.compareTo(pair2) < 0); } | public int compareTo(Object o) { return compareTo((StringPair) o); } | StringPair implements Comparable, WritableComparable { public int compareTo(Object o) { return compareTo((StringPair) o); } } | StringPair implements Comparable, WritableComparable { public int compareTo(Object o) { return compareTo((StringPair) o); } StringPair(); StringPair(String x, String y); } | StringPair implements Comparable, WritableComparable { public int compareTo(Object o) { return compareTo((StringPair) o); } StringPair(); StringPair(String x, String y); int compareTo(Object o); void write(DataOutput out); void readFields(DataInput in); int compareTo(StringPair w); boolean equals(Object o); int hashCo... | StringPair implements Comparable, WritableComparable { public int compareTo(Object o) { return compareTo((StringPair) o); } StringPair(); StringPair(String x, String y); int compareTo(Object o); void write(DataOutput out); void readFields(DataInput in); int compareTo(StringPair w); boolean equals(Object o); int hashCo... |
@Test public void resolveAddElapsedTimeTest() { var et = Duration.ofMinutes(2); var ts = now.plus(et); var vi = new VideoIndex(ts); var rvi = VideoIndexUtils.resolve(vi, media1); assertTrue(rvi.getTimestamp().isPresent()); assertEquals(ts, rvi.getTimestamp().get()); assertTrue(rvi.getElapsedTime().isPresent()); assertE... | public static VideoIndex resolve(VideoIndex videoIndex, Media media) { VideoIndex vi = videoIndex; if (videoIndex.getElapsedTime().isEmpty() && videoIndex.getTimestamp().isPresent()) { Instant endTimestamp = media.getStartTimestamp().plus(media.getDuration()); Instant timestamp = videoIndex.getTimestamp().get(); if (ti... | VideoIndexUtils { public static VideoIndex resolve(VideoIndex videoIndex, Media media) { VideoIndex vi = videoIndex; if (videoIndex.getElapsedTime().isEmpty() && videoIndex.getTimestamp().isPresent()) { Instant endTimestamp = media.getStartTimestamp().plus(media.getDuration()); Instant timestamp = videoIndex.getTimesta... | VideoIndexUtils { public static VideoIndex resolve(VideoIndex videoIndex, Media media) { VideoIndex vi = videoIndex; if (videoIndex.getElapsedTime().isEmpty() && videoIndex.getTimestamp().isPresent()) { Instant endTimestamp = media.getStartTimestamp().plus(media.getDuration()); Instant timestamp = videoIndex.getTimesta... | VideoIndexUtils { public static VideoIndex resolve(VideoIndex videoIndex, Media media) { VideoIndex vi = videoIndex; if (videoIndex.getElapsedTime().isEmpty() && videoIndex.getTimestamp().isPresent()) { Instant endTimestamp = media.getStartTimestamp().plus(media.getDuration()); Instant timestamp = videoIndex.getTimesta... | VideoIndexUtils { public static VideoIndex resolve(VideoIndex videoIndex, Media media) { VideoIndex vi = videoIndex; if (videoIndex.getElapsedTime().isEmpty() && videoIndex.getTimestamp().isPresent()) { Instant endTimestamp = media.getStartTimestamp().plus(media.getDuration()); Instant timestamp = videoIndex.getTimesta... |
@Test public void resolveAddTimestampTest() { var et = Duration.ofMinutes(2); var ts = now.plus(et); var vi = new VideoIndex(et); var rvi = VideoIndexUtils.resolve(vi, media1); assertTrue(rvi.getTimestamp().isPresent()); assertEquals(ts, rvi.getTimestamp().get()); assertTrue(rvi.getElapsedTime().isPresent()); assertEqu... | public static VideoIndex resolve(VideoIndex videoIndex, Media media) { VideoIndex vi = videoIndex; if (videoIndex.getElapsedTime().isEmpty() && videoIndex.getTimestamp().isPresent()) { Instant endTimestamp = media.getStartTimestamp().plus(media.getDuration()); Instant timestamp = videoIndex.getTimestamp().get(); if (ti... | VideoIndexUtils { public static VideoIndex resolve(VideoIndex videoIndex, Media media) { VideoIndex vi = videoIndex; if (videoIndex.getElapsedTime().isEmpty() && videoIndex.getTimestamp().isPresent()) { Instant endTimestamp = media.getStartTimestamp().plus(media.getDuration()); Instant timestamp = videoIndex.getTimesta... | VideoIndexUtils { public static VideoIndex resolve(VideoIndex videoIndex, Media media) { VideoIndex vi = videoIndex; if (videoIndex.getElapsedTime().isEmpty() && videoIndex.getTimestamp().isPresent()) { Instant endTimestamp = media.getStartTimestamp().plus(media.getDuration()); Instant timestamp = videoIndex.getTimesta... | VideoIndexUtils { public static VideoIndex resolve(VideoIndex videoIndex, Media media) { VideoIndex vi = videoIndex; if (videoIndex.getElapsedTime().isEmpty() && videoIndex.getTimestamp().isPresent()) { Instant endTimestamp = media.getStartTimestamp().plus(media.getDuration()); Instant timestamp = videoIndex.getTimesta... | VideoIndexUtils { public static VideoIndex resolve(VideoIndex videoIndex, Media media) { VideoIndex vi = videoIndex; if (videoIndex.getElapsedTime().isEmpty() && videoIndex.getTimestamp().isPresent()) { Instant endTimestamp = media.getStartTimestamp().plus(media.getDuration()); Instant timestamp = videoIndex.getTimesta... |
@Test public void testPager() { var data = new ArrayList<Integer>(); for (var i = 0; i < 1000; i++) { data.add(i); } var pager = new Pager<>((limit, offset) -> { var start = offset; Long end = limit + offset; if (start > data.size()) { start = (long) data.size() - 1; } if (end >= data.size()) { end = (long) data.size()... | public Pager(BiFunction<Long, Long, T> fetchFn, Long limit, Long pageSize) { Function<RequestPager.Page, T> fn = (page) -> { try { return fetchFn.apply(page.getLimit(), page.getOffset()); } catch (Exception e) { Long start = page.getOffset(); Long end = start + page.getLimit(); throw new RuntimeException("Page request ... | Pager implements Runnable { public Pager(BiFunction<Long, Long, T> fetchFn, Long limit, Long pageSize) { Function<RequestPager.Page, T> fn = (page) -> { try { return fetchFn.apply(page.getLimit(), page.getOffset()); } catch (Exception e) { Long start = page.getOffset(); Long end = start + page.getLimit(); throw new Run... | Pager implements Runnable { public Pager(BiFunction<Long, Long, T> fetchFn, Long limit, Long pageSize) { Function<RequestPager.Page, T> fn = (page) -> { try { return fetchFn.apply(page.getLimit(), page.getOffset()); } catch (Exception e) { Long start = page.getOffset(); Long end = start + page.getLimit(); throw new Run... | Pager implements Runnable { public Pager(BiFunction<Long, Long, T> fetchFn, Long limit, Long pageSize) { Function<RequestPager.Page, T> fn = (page) -> { try { return fetchFn.apply(page.getLimit(), page.getOffset()); } catch (Exception e) { Long start = page.getOffset(); Long end = start + page.getLimit(); throw new Run... | Pager implements Runnable { public Pager(BiFunction<Long, Long, T> fetchFn, Long limit, Long pageSize) { Function<RequestPager.Page, T> fn = (page) -> { try { return fetchFn.apply(page.getLimit(), page.getOffset()); } catch (Exception e) { Long start = page.getOffset(); Long end = start + page.getLimit(); throw new Run... |
@Ignore @Test public void testImageCapture() throws Exception { AVFImageCapture ic = new AVFImageCapture(); String[] devices = ic.videoDevicesAsStrings(); if (devices.length > 0) { ic.startSessionWithNamedDevice(devices[0]); Path path = Paths.get("target", getClass().getSimpleName() + "-0-" + Instant.now() + ".png"); O... | @Override public Framegrab capture(File file) { Framegrab framegrab = new Framegrab(); start(); Optional<Image> imageOpt = imageCapture.capture(file, Duration.ofSeconds(10)); if (imageOpt.isPresent()) { framegrab.setImage(imageOpt.get()); MediaPlayer<? extends VideoState, ? extends VideoError> mediaPlayer = Initializer... | AVFImageCaptureService implements SelectableImageCaptureService { @Override public Framegrab capture(File file) { Framegrab framegrab = new Framegrab(); start(); Optional<Image> imageOpt = imageCapture.capture(file, Duration.ofSeconds(10)); if (imageOpt.isPresent()) { framegrab.setImage(imageOpt.get()); MediaPlayer<? e... | AVFImageCaptureService implements SelectableImageCaptureService { @Override public Framegrab capture(File file) { Framegrab framegrab = new Framegrab(); start(); Optional<Image> imageOpt = imageCapture.capture(file, Duration.ofSeconds(10)); if (imageOpt.isPresent()) { framegrab.setImage(imageOpt.get()); MediaPlayer<? e... | AVFImageCaptureService implements SelectableImageCaptureService { @Override public Framegrab capture(File file) { Framegrab framegrab = new Framegrab(); start(); Optional<Image> imageOpt = imageCapture.capture(file, Duration.ofSeconds(10)); if (imageOpt.isPresent()) { framegrab.setImage(imageOpt.get()); MediaPlayer<? e... | AVFImageCaptureService implements SelectableImageCaptureService { @Override public Framegrab capture(File file) { Framegrab framegrab = new Framegrab(); start(); Optional<Image> imageOpt = imageCapture.capture(file, Duration.ofSeconds(10)); if (imageOpt.isPresent()) { framegrab.setImage(imageOpt.get()); MediaPlayer<? e... |
@Test public void getSettingsDirectoryTest() { Path path = Initializer.getSettingsDirectory(); assertNotNull("The Settings directory was null", path); assertTrue("The settings directory does not exist", Files.exists(path)); } | public static Path getSettingsDirectory() { if (settingsDirectory == null) { String home = System.getProperty("user.home"); Path path = Paths.get(home, ".vars"); settingsDirectory = createDirectory(path); if (settingsDirectory == null) { log.warn("Failed to create settings directory at " + path); } } return settingsDir... | Initializer { public static Path getSettingsDirectory() { if (settingsDirectory == null) { String home = System.getProperty("user.home"); Path path = Paths.get(home, ".vars"); settingsDirectory = createDirectory(path); if (settingsDirectory == null) { log.warn("Failed to create settings directory at " + path); } } retu... | Initializer { public static Path getSettingsDirectory() { if (settingsDirectory == null) { String home = System.getProperty("user.home"); Path path = Paths.get(home, ".vars"); settingsDirectory = createDirectory(path); if (settingsDirectory == null) { log.warn("Failed to create settings directory at " + path); } } retu... | Initializer { public static Path getSettingsDirectory() { if (settingsDirectory == null) { String home = System.getProperty("user.home"); Path path = Paths.get(home, ".vars"); settingsDirectory = createDirectory(path); if (settingsDirectory == null) { log.warn("Failed to create settings directory at " + path); } } retu... | Initializer { public static Path getSettingsDirectory() { if (settingsDirectory == null) { String home = System.getProperty("user.home"); Path path = Paths.get(home, ".vars"); settingsDirectory = createDirectory(path); if (settingsDirectory == null) { log.warn("Failed to create settings directory at " + path); } } retu... |
@Ignore @Test public void getToolBoxTest() throws Exception { UIToolBox toolBox = Initializer.getToolBox(); assertNotNull("UIToolBox was null", toolBox); Data data = toolBox.getData(); assertNotNull("Data in toolbox was null", data); Services services = toolBox.getServices(); assertNotNull("Services in toolbox was null... | public static UIToolBox getToolBox() { if (toolBox == null) { Services services = ServicesBuilder.build(Initializer.getConfig()); ResourceBundle bundle = ResourceBundle.getBundle("i18n", Locale.getDefault()); LessCSSLoader lessLoader = new LessCSSLoader(); String stylesheet = lessLoader.loadLess(Initializer.class.getRe... | Initializer { public static UIToolBox getToolBox() { if (toolBox == null) { Services services = ServicesBuilder.build(Initializer.getConfig()); ResourceBundle bundle = ResourceBundle.getBundle("i18n", Locale.getDefault()); LessCSSLoader lessLoader = new LessCSSLoader(); String stylesheet = lessLoader.loadLess(Initializ... | Initializer { public static UIToolBox getToolBox() { if (toolBox == null) { Services services = ServicesBuilder.build(Initializer.getConfig()); ResourceBundle bundle = ResourceBundle.getBundle("i18n", Locale.getDefault()); LessCSSLoader lessLoader = new LessCSSLoader(); String stylesheet = lessLoader.loadLess(Initializ... | Initializer { public static UIToolBox getToolBox() { if (toolBox == null) { Services services = ServicesBuilder.build(Initializer.getConfig()); ResourceBundle bundle = ResourceBundle.getBundle("i18n", Locale.getDefault()); LessCSSLoader lessLoader = new LessCSSLoader(); String stylesheet = lessLoader.loadLess(Initializ... | Initializer { public static UIToolBox getToolBox() { if (toolBox == null) { Services services = ServicesBuilder.build(Initializer.getConfig()); ResourceBundle bundle = ResourceBundle.getBundle("i18n", Locale.getDefault()); LessCSSLoader lessLoader = new LessCSSLoader(); String stylesheet = lessLoader.loadLess(Initializ... |
@Test public void testAdd() throws Exception { final TestAdapter adapter = new TestAdapter(); adapter.add("one"); assertEquals(2, adapter.getItemCount()); adapter.add("two"); assertEquals(4, adapter.getItemCount()); adapter.add("three"); assertEquals(6, adapter.getItemCount()); } | public void add(@NonNull final T item) { add(mItems.size(), item, true); } | GraywaterAdapter extends RecyclerView.Adapter<VH> { public void add(@NonNull final T item) { add(mItems.size(), item, true); } } | GraywaterAdapter extends RecyclerView.Adapter<VH> { public void add(@NonNull final T item) { add(mItems.size(), item, true); } } | GraywaterAdapter extends RecyclerView.Adapter<VH> { public void add(@NonNull final T item) { add(mItems.size(), item, true); } @Override int getItemViewType(final int position); @Override VH onCreateViewHolder(final ViewGroup parent, final int viewType); @Override @SuppressLint("RecyclerView") void onBindViewHolder(fi... | GraywaterAdapter extends RecyclerView.Adapter<VH> { public void add(@NonNull final T item) { add(mItems.size(), item, true); } @Override int getItemViewType(final int position); @Override VH onCreateViewHolder(final ViewGroup parent, final int viewType); @Override @SuppressLint("RecyclerView") void onBindViewHolder(fi... |
@Test public void testRemove() throws Exception { final TestAdapter adapter = new TestAdapter(); adapter.add("zero"); adapter.add("one"); adapter.add("two"); adapter.add("three"); adapter.add("four"); adapter.add("five"); adapter.remove(0); assertEquals(2 * 5, adapter.getItemCount()); adapter.remove(4); assertEquals(2 ... | @Nullable public T remove(final int itemPosition) { return remove(itemPosition, true); } | GraywaterAdapter extends RecyclerView.Adapter<VH> { @Nullable public T remove(final int itemPosition) { return remove(itemPosition, true); } } | GraywaterAdapter extends RecyclerView.Adapter<VH> { @Nullable public T remove(final int itemPosition) { return remove(itemPosition, true); } } | GraywaterAdapter extends RecyclerView.Adapter<VH> { @Nullable public T remove(final int itemPosition) { return remove(itemPosition, true); } @Override int getItemViewType(final int position); @Override VH onCreateViewHolder(final ViewGroup parent, final int viewType); @Override @SuppressLint("RecyclerView") void onBin... | GraywaterAdapter extends RecyclerView.Adapter<VH> { @Nullable public T remove(final int itemPosition) { return remove(itemPosition, true); } @Override int getItemViewType(final int position); @Override VH onCreateViewHolder(final ViewGroup parent, final int viewType); @Override @SuppressLint("RecyclerView") void onBin... |
@Test public void testGetItemViewType() throws Exception { final TestAdapter adapter = new TestAdapter(); adapter.add(Uri.parse("https: assertEquals(3, adapter.getItemCount()); adapter.add("one"); assertEquals(5, adapter.getItemCount()); adapter.add(Uri.parse("http: assertEquals(8, adapter.getItemCount()); adapter.add(... | @Override public int getItemViewType(final int position) { return internalGetItemViewType(position); } | GraywaterAdapter extends RecyclerView.Adapter<VH> { @Override public int getItemViewType(final int position) { return internalGetItemViewType(position); } } | GraywaterAdapter extends RecyclerView.Adapter<VH> { @Override public int getItemViewType(final int position) { return internalGetItemViewType(position); } } | GraywaterAdapter extends RecyclerView.Adapter<VH> { @Override public int getItemViewType(final int position) { return internalGetItemViewType(position); } @Override int getItemViewType(final int position); @Override VH onCreateViewHolder(final ViewGroup parent, final int viewType); @Override @SuppressLint("RecyclerVie... | GraywaterAdapter extends RecyclerView.Adapter<VH> { @Override public int getItemViewType(final int position) { return internalGetItemViewType(position); } @Override int getItemViewType(final int position); @Override VH onCreateViewHolder(final ViewGroup parent, final int viewType); @Override @SuppressLint("RecyclerVie... |
@Test public void testClear() throws Exception { final TestAdapter adapter = new TestAdapter(); final Uri tumblrUri = Uri.parse("https: adapter.add(tumblrUri); assertEquals(3, adapter.getItemCount()); adapter.add("one"); assertEquals(5, adapter.getItemCount()); adapter.add(Uri.parse("http: assertEquals(8, adapter.getIt... | public void clear() { mItems.clear(); mBinderListCache.clear(); mViewHolderToItemPositionCache.clear(); mItemPositionToFirstViewHolderPositionCache.clear(); mViewHolderPreparedCache.clear(); mPreviousBoundViewHolderPosition = NO_PREVIOUS_BOUND_VIEWHOLDER; } | GraywaterAdapter extends RecyclerView.Adapter<VH> { public void clear() { mItems.clear(); mBinderListCache.clear(); mViewHolderToItemPositionCache.clear(); mItemPositionToFirstViewHolderPositionCache.clear(); mViewHolderPreparedCache.clear(); mPreviousBoundViewHolderPosition = NO_PREVIOUS_BOUND_VIEWHOLDER; } } | GraywaterAdapter extends RecyclerView.Adapter<VH> { public void clear() { mItems.clear(); mBinderListCache.clear(); mViewHolderToItemPositionCache.clear(); mItemPositionToFirstViewHolderPositionCache.clear(); mViewHolderPreparedCache.clear(); mPreviousBoundViewHolderPosition = NO_PREVIOUS_BOUND_VIEWHOLDER; } } | GraywaterAdapter extends RecyclerView.Adapter<VH> { public void clear() { mItems.clear(); mBinderListCache.clear(); mViewHolderToItemPositionCache.clear(); mItemPositionToFirstViewHolderPositionCache.clear(); mViewHolderPreparedCache.clear(); mPreviousBoundViewHolderPosition = NO_PREVIOUS_BOUND_VIEWHOLDER; } @Override... | GraywaterAdapter extends RecyclerView.Adapter<VH> { public void clear() { mItems.clear(); mBinderListCache.clear(); mViewHolderToItemPositionCache.clear(); mItemPositionToFirstViewHolderPositionCache.clear(); mViewHolderPreparedCache.clear(); mPreviousBoundViewHolderPosition = NO_PREVIOUS_BOUND_VIEWHOLDER; } @Override... |
@Test public void testCanonicalize() { assertEquals("/", ZNodePath.canonicalize("/")); assertEquals("/", ZNodePath.canonicalize(" assertEquals("/", ZNodePath.canonicalize(" assertEquals("/a", ZNodePath.canonicalize("/a")); assertEquals("/a", ZNodePath.canonicalize("/a/")); assertEquals("/", ZNodePath.canonicalize("/.")... | public static String canonicalize(final String path) { final int length = path.length(); int lastSlash = -1; StringBuilder builder = null; for (int i=0; i<length; ++i) { char c = path.charAt(i); if ((c == SLASH) || (i == length - 1)) { if (i > 0) { if ((c == SLASH) && (lastSlash == i-1)) { if (builder == null) { builde... | ZNodePath extends ZNodeLabelVector { public static String canonicalize(final String path) { final int length = path.length(); int lastSlash = -1; StringBuilder builder = null; for (int i=0; i<length; ++i) { char c = path.charAt(i); if ((c == SLASH) || (i == length - 1)) { if (i > 0) { if ((c == SLASH) && (lastSlash == ... | ZNodePath extends ZNodeLabelVector { public static String canonicalize(final String path) { final int length = path.length(); int lastSlash = -1; StringBuilder builder = null; for (int i=0; i<length; ++i) { char c = path.charAt(i); if ((c == SLASH) || (i == length - 1)) { if (i > 0) { if ((c == SLASH) && (lastSlash == ... | ZNodePath extends ZNodeLabelVector { public static String canonicalize(final String path) { final int length = path.length(); int lastSlash = -1; StringBuilder builder = null; for (int i=0; i<length; ++i) { char c = path.charAt(i); if ((c == SLASH) || (i == length - 1)) { if (i > 0) { if ((c == SLASH) && (lastSlash == ... | ZNodePath extends ZNodeLabelVector { public static String canonicalize(final String path) { final int length = path.length(); int lastSlash = -1; StringBuilder builder = null; for (int i=0; i<length; ++i) { char c = path.charAt(i); if ((c == SLASH) || (i == length - 1)) { if (i > 0) { if ((c == SLASH) && (lastSlash == ... |
@Test(expected = IllegalArgumentException.class) public void testCheckNotContainsNull_nullIterable() { IterableNullChecker.checkNotContainsNull(null, ""); } | public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, errorMessage); } return ... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... |
@Test public void testCheckNotContainsNull_emptyIterable() { IterableNullChecker.checkNotContainsNull(new ArrayList<>(), ""); } | public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, errorMessage); } return ... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... |
@Test(expected = IllegalArgumentException.class) public void testCheckNotContainsNull_iterableContainingOnlyNull() { final List<Object> list = new ArrayList<>(); list.add(null); IterableNullChecker.checkNotContainsNull(list, ""); } | public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, errorMessage); } return ... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... |
@Test(expected = IllegalArgumentException.class) public void testCheckNotContainsNull_iterableContainingNullAndOtherValues() { final List<Object> list = new ArrayList<>(); list.add(null); list.add("hello"); IterableNullChecker.checkNotContainsNull(list, ""); } | public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, errorMessage); } return ... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... |
@Test public void testCheckNotContainsNull_iterableContainingOnlyNonNullValues() { final List<Object> list = new ArrayList<>(); list.add("hello"); list.add("world"); IterableNullChecker.checkNotContainsNull(list, ""); } | public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, errorMessage); } return ... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... |
@Test(expected = IllegalArgumentException.class) public void testCheckNotContainsNull_nullErrorMessage() { IterableNullChecker.checkNotContainsNull(new ArrayList<>(), null); } | public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, errorMessage); } return ... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... |
@SuppressWarnings("deprecation") @Test public void testTakeItem() { ItemStack IS = new ItemStack(Material.STONE, 64); ItemStack IS2 = new ItemStack(Material.STONE, 64, (short) 1); FakeInventory inv = fInventory(this, IS, IS2); Player mockPlayer = Mockito.mock(Player.class); PlayerInventory mockInventory = preparePlayer... | @Deprecated public boolean takeItem(Player player, int id, int amount) { ItemStack IS = new ItemStack(id, amount); if (!player.getInventory().containsAtLeast(IS, amount)) return false; player.getInventory().removeItem(IS); return true; } | CommonFunctions extends AbstractCommonFunctions implements SelfReference { @Deprecated public boolean takeItem(Player player, int id, int amount) { ItemStack IS = new ItemStack(id, amount); if (!player.getInventory().containsAtLeast(IS, amount)) return false; player.getInventory().removeItem(IS); return true; } } | CommonFunctions extends AbstractCommonFunctions implements SelfReference { @Deprecated public boolean takeItem(Player player, int id, int amount) { ItemStack IS = new ItemStack(id, amount); if (!player.getInventory().containsAtLeast(IS, amount)) return false; player.getInventory().removeItem(IS); return true; } CommonF... | CommonFunctions extends AbstractCommonFunctions implements SelfReference { @Deprecated public boolean takeItem(Player player, int id, int amount) { ItemStack IS = new ItemStack(id, amount); if (!player.getInventory().containsAtLeast(IS, amount)) return false; player.getInventory().removeItem(IS); return true; } CommonF... | CommonFunctions extends AbstractCommonFunctions implements SelfReference { @Deprecated public boolean takeItem(Player player, int id, int amount) { ItemStack IS = new ItemStack(id, amount); if (!player.getInventory().containsAtLeast(IS, amount)) return false; player.getInventory().removeItem(IS); return true; } CommonF... |
@Test public void testCurrentAreaAt() { } | public String currentAreaAt(Location location) { String[] areaNames = currentAreasAt(location); return areaNames.length > 0 ? areaNames[0] : null; } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String currentAreaAt(Location location) { String[] areaNames = currentAreasAt(location); return areaNames.length > 0 ? areaNames[0] : null; } } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String currentAreaAt(Location location) { String[] areaNames = currentAreasAt(location); return areaNames.length > 0 ? areaNames[0] : null; } AbstractCommonFunctions(TriggerReacto... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String currentAreaAt(Location location) { String[] areaNames = currentAreasAt(location); return areaNames.length > 0 ? areaNames[0] : null; } AbstractCommonFunctions(TriggerReacto... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String currentAreaAt(Location location) { String[] areaNames = currentAreasAt(location); return areaNames.length > 0 ? areaNames[0] : null; } AbstractCommonFunctions(TriggerReacto... |
@Test public void testCurrentAreas() { } | public String[] currentAreas(Entity entity) { return currentAreasAt(entity.getLocation()); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String[] currentAreas(Entity entity) { return currentAreasAt(entity.getLocation()); } } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String[] currentAreas(Entity entity) { return currentAreasAt(entity.getLocation()); } AbstractCommonFunctions(TriggerReactorCore plugin); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String[] currentAreas(Entity entity) { return currentAreasAt(entity.getLocation()); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated a... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String[] currentAreas(Entity entity) { return currentAreasAt(entity.getLocation()); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated a... |
@Test public void testCurrentAreasAt() { } | public String[] currentAreasAt(Location location) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); String[] names = areaManager.getAreas(LocationUtil.convertToSimpleLocation(location)).stream() .map(Map.Entry::getValue) .map(Trigger::getTriggerName) .toArray(String[]::new); return names; } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String[] currentAreasAt(Location location) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); String[] names = areaManager.getAreas(LocationUtil.convertToSimpleLo... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String[] currentAreasAt(Location location) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); String[] names = areaManager.getAreas(LocationUtil.convertToSimpleLo... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String[] currentAreasAt(Location location) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); String[] names = areaManager.getAreas(LocationUtil.convertToSimpleLo... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String[] currentAreasAt(Location location) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); String[] names = areaManager.getAreas(LocationUtil.convertToSimpleLo... |
@Test public void testGetEntitiesInArea() { } | public List<Entity> getEntitiesInArea(String areaTriggerName) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); AreaTrigger trigger = areaManager.getArea(areaTriggerName); if (trigger == null) return null; List<Entity> entities = new ArrayList<>(); for (IEntity ie : trigger.getEntities()) entities.add... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public List<Entity> getEntitiesInArea(String areaTriggerName) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); AreaTrigger trigger = areaManager.getArea(areaTriggerNam... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public List<Entity> getEntitiesInArea(String areaTriggerName) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); AreaTrigger trigger = areaManager.getArea(areaTriggerNam... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public List<Entity> getEntitiesInArea(String areaTriggerName) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); AreaTrigger trigger = areaManager.getArea(areaTriggerNam... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public List<Entity> getEntitiesInArea(String areaTriggerName) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); AreaTrigger trigger = areaManager.getArea(areaTriggerNam... |
@Test public void testColor() { Assert.assertEquals(ChatColor.RED + "My message", fn.color("&cMy message")); } | public String color(String str) { return ChatColor.translateAlternateColorCodes('&', str); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String color(String str) { return ChatColor.translateAlternateColorCodes('&', str); } } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String color(String str) { return ChatColor.translateAlternateColorCodes('&', str); } AbstractCommonFunctions(TriggerReactorCore plugin); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String color(String str) { return ChatColor.translateAlternateColorCodes('&', str); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated a... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String color(String str) { return ChatColor.translateAlternateColorCodes('&', str); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated a... |
@Test public void testBukkitColor() { Color expect = Color.fromRGB(3, 6, 8); Color result = fn.bukkitColor(3, 6, 8); Assert.assertEquals(expect.asBGR(), result.asBGR()); } | public Color bukkitColor(int red, int green, int blue) { return Color.fromRGB(red, green, blue); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Color bukkitColor(int red, int green, int blue) { return Color.fromRGB(red, green, blue); } } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Color bukkitColor(int red, int green, int blue) { return Color.fromRGB(red, green, blue); } AbstractCommonFunctions(TriggerReactorCore plugin); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Color bukkitColor(int red, int green, int blue) { return Color.fromRGB(red, green, blue); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprec... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Color bukkitColor(int red, int green, int blue) { return Color.fromRGB(red, green, blue); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprec... |
@Test public abstract void testItem(); | @Deprecated public abstract ItemStack item(int type, int amount, int data); | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { @Deprecated public abstract ItemStack item(int type, int amount, int data); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { @Deprecated public abstract ItemStack item(int type, int amount, int data); AbstractCommonFunctions(TriggerReactorCore plugin); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { @Deprecated public abstract ItemStack item(int type, int amount, int data); AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstract boolean t... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { @Deprecated public abstract ItemStack item(int type, int amount, int data); AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstract boolean t... |
@Test public void testGetItemTitle() { ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> "abc").when(mockItemMeta).getDisplayName(); Assert.assertEquals("abc", fn.getItemTitle(IS)); } | public String getItemTitle(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return ""; String dispName = IM.getDisplayName(); return dispName == null ? "" : dispName; } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String getItemTitle(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return ""; String dispName = IM.getDisplayName(); return dispName == null ? "" : dispName; } } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String getItemTitle(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return ""; String dispName = IM.getDisplayName(); return dispName == null ? "" : dispName; } Ab... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String getItemTitle(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return ""; String dispName = IM.getDisplayName(); return dispName == null ? "" : dispName; } Ab... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String getItemTitle(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return ""; String dispName = IM.getDisplayName(); return dispName == null ? "" : dispName; } Ab... |
@Test public void testSetItemTitle() { ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> { title = invocation.getArgument(0); return null; }).when(mockItemMeta).setDisplayName(Mockito.anyString()); fn.setItemTitle(IS, "xyz"); Assert.assertEquals("xyz", title); } | public void setItemTitle(ItemStack IS, String title) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; IM.setDisplayName(color(title)); IS.setItemMeta(IM); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void setItemTitle(ItemStack IS, String title) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; IM.... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void setItemTitle(ItemStack IS, String title) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; IM.... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void setItemTitle(ItemStack IS, String title) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; IM.... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void setItemTitle(ItemStack IS, String title) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; IM.... |
@Test public void testHasLore() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); Assert.assertTrue(fn.hasLore(IS, "abab")); Assert.assertFalse(fn.hasLore(IS, "hoho")); } | public boolean hasLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return false; List<String> lores = IM.getLore(); if (lores == null) return false; return lores.contains(lore); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public boolean hasLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return false; List<String> lores = IM.getLore(); if (lores == null) return false; retu... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public boolean hasLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return false; List<String> lores = IM.getLore(); if (lores == null) return false; retu... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public boolean hasLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return false; List<String> lores = IM.getLore(); if (lores == null) return false; retu... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public boolean hasLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return false; List<String> lores = IM.getLore(); if (lores == null) return false; retu... |
@SuppressWarnings("deprecation") @Test public void testItem() { ItemStack IS = new ItemStack(Material.STONE, 64); ItemStack IS2 = new ItemStack(Material.STONE, 63, (short) 1); Assert.assertTrue(isEqual(IS, fn.item("STONE", 64))); Assert.assertTrue(isEqual(IS2, fn.item("STONE", 63, 1))); Assert.assertTrue(isEqual(IS, fn... | @Deprecated public ItemStack item(int type, int amount, int data) { return new ItemStack(type, amount, (short) data); } | CommonFunctions extends AbstractCommonFunctions implements SelfReference { @Deprecated public ItemStack item(int type, int amount, int data) { return new ItemStack(type, amount, (short) data); } } | CommonFunctions extends AbstractCommonFunctions implements SelfReference { @Deprecated public ItemStack item(int type, int amount, int data) { return new ItemStack(type, amount, (short) data); } CommonFunctions(TriggerReactorCore plugin); } | CommonFunctions extends AbstractCommonFunctions implements SelfReference { @Deprecated public ItemStack item(int type, int amount, int data) { return new ItemStack(type, amount, (short) data); } CommonFunctions(TriggerReactorCore plugin); @Deprecated boolean takeItem(Player player, int id, int amount); boolean takeItem... | CommonFunctions extends AbstractCommonFunctions implements SelfReference { @Deprecated public ItemStack item(int type, int amount, int data) { return new ItemStack(type, amount, (short) data); } CommonFunctions(TriggerReactorCore plugin); @Deprecated boolean takeItem(Player player, int id, int amount); boolean takeItem... |
@Test public void testGetLore() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); Assert.assertEquals("abab", fn.getLore(IS, 0)); Assert.assertEquals("cdcd", fn.getLore(IS, 1))... | public String getLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return null; List<String> lores = IM.getLore(); if (lores == null) return null; if (index < 0 || index >= lores.size()) return null; return lores.get(index); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String getLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return null; List<String> lores = IM.getLore(); if (lores == null) return null; if (index... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String getLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return null; List<String> lores = IM.getLore(); if (lores == null) return null; if (index... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String getLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return null; List<String> lores = IM.getLore(); if (lores == null) return null; if (index... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String getLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return null; List<String> lores = IM.getLore(); if (lores == null) return null; if (index... |
@Test public void testAddLore() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); fn.addLore(IS, "efef"); Assert.assertEquals(3, lores.size()); Assert.assertEquals("efef", lore... | public void addLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<String> lores = IM.getLore(); if (lores == null) lores = new ArrayList<>(); lores.add(color(lore)); IM.setLore(lores); IS.setItemMeta(IM);... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void addLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<Stri... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void addLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<Stri... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void addLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<Stri... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void addLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<Stri... |
@Test public void testSetLore() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); fn.setLore(IS, 0, "pqpq"); Assert.assertEquals("pqpq", lores.get(0)); fn.setLore(IS, 5, "ffee"... | public void setLore(ItemStack IS, int index, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<String> lores = IM.getLore(); if (lores == null) lores = new ArrayList<>(); while (index >= lores.size()) lores.add(""); lores.... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void setLore(ItemStack IS, int index, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void setLore(ItemStack IS, int index, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void setLore(ItemStack IS, int index, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void setLore(ItemStack IS, int index, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return... |
@Test public void testRemoveLore() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); lores.add("efef"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); fn.removeLore(IS, 2); Assert.assertEquals(2, lores.size()); Assert.asser... | public void removeLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<String> lores = IM.getLore(); if (lores == null) lores = new ArrayList<>(); if (index < 0 || index >= lores.size()) return; lores.remove(... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void removeLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<Str... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void removeLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<Str... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void removeLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<Str... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void removeLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<Str... |
@Test public void testClearLore() { ItemStack IS = new ItemStack(Material.STONE); ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class); fn.clearLore(IS); Mockito.verify(mockItemMeta).setLore(captor.capture()); Assert.assertEquals(0, captor.getValue().size()); } | public void clearLore(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return; IM.setLore(new ArrayList<>()); IS.setItemMeta(IM); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void clearLore(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return; IM.setLore(new ArrayList<>()); IS.setItemMeta(IM); } } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void clearLore(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return; IM.setLore(new ArrayList<>()); IS.setItemMeta(IM); } AbstractCommonFunctions(TriggerReactorC... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void clearLore(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return; IM.setLore(new ArrayList<>()); IS.setItemMeta(IM); } AbstractCommonFunctions(TriggerReactorC... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void clearLore(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return; IM.setLore(new ArrayList<>()); IS.setItemMeta(IM); } AbstractCommonFunctions(TriggerReactorC... |
@Test public void testLoreSize() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); lores.add("efef"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); Assert.assertEquals(3, fn.loreSize(IS)); } | public int loreSize(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return 0; List<String> lores = IM.getLore(); if (lores == null) return 0; return lores.size(); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public int loreSize(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return 0; List<String> lores = IM.getLore(); if (lores == null) return 0; return lores.size(); } } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public int loreSize(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return 0; List<String> lores = IM.getLore(); if (lores == null) return 0; return lores.size(); } Abstr... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public int loreSize(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return 0; List<String> lores = IM.getLore(); if (lores == null) return 0; return lores.size(); } Abstr... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public int loreSize(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return 0; List<String> lores = IM.getLore(); if (lores == null) return 0; return lores.size(); } Abstr... |
@Test public void testFormatCurrency() { Assert.assertEquals("$3,234,463.44", fn.formatCurrency(3234463.44)); Assert.assertEquals("$3,234,463.44", fn.formatCurrency(3234463.44, "en", "US")); Assert.assertEquals("\u00a33,234,463.44", fn.formatCurrency(3234463.44, "en", "GB")); } | @Override public String formatCurrency(double money, String locale1, String locale2) { Locale locale = new Locale(locale1, locale2); NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance(locale); return currencyFormatter.format(money); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { @Override public String formatCurrency(double money, String locale1, String locale2) { Locale locale = new Locale(locale1, locale2); NumberFormat currencyFormatter = NumberFormat.getCurr... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { @Override public String formatCurrency(double money, String locale1, String locale2) { Locale locale = new Locale(locale1, locale2); NumberFormat currencyFormatter = NumberFormat.getCurr... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { @Override public String formatCurrency(double money, String locale1, String locale2) { Locale locale = new Locale(locale1, locale2); NumberFormat currencyFormatter = NumberFormat.getCurr... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { @Override public String formatCurrency(double money, String locale1, String locale2) { Locale locale = new Locale(locale1, locale2); NumberFormat currencyFormatter = NumberFormat.getCurr... |
@Test public void testGetTargetBlock() { fn.getTargetBlock(mockPlayer, 30); Mockito.verify(mockPlayer).getTargetBlock(null, 30); } | public Block getTargetBlock(Player player, int maxDistance) { return player.getTargetBlock(null, maxDistance); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Block getTargetBlock(Player player, int maxDistance) { return player.getTargetBlock(null, maxDistance); } } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Block getTargetBlock(Player player, int maxDistance) { return player.getTargetBlock(null, maxDistance); } AbstractCommonFunctions(TriggerReactorCore plugin); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Block getTargetBlock(Player player, int maxDistance) { return player.getTargetBlock(null, maxDistance); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String ... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Block getTargetBlock(Player player, int maxDistance) { return player.getTargetBlock(null, maxDistance); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String ... |
@Test public abstract void testHeadForName(); | public ItemStack headForName(String targetName) { return headForName(targetName, 1); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public ItemStack headForName(String targetName) { return headForName(targetName, 1); } } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public ItemStack headForName(String targetName) { return headForName(targetName, 1); } AbstractCommonFunctions(TriggerReactorCore plugin); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public ItemStack headForName(String targetName) { return headForName(targetName, 1); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstrac... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public ItemStack headForName(String targetName) { return headForName(targetName, 1); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstrac... |
@Test public abstract void testHeadForValue(); | public abstract ItemStack headForValue(String textureValue); | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public abstract ItemStack headForValue(String textureValue); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public abstract ItemStack headForValue(String textureValue); AbstractCommonFunctions(TriggerReactorCore plugin); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public abstract ItemStack headForValue(String textureValue); AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstract boolean takeItem(Player ... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public abstract ItemStack headForValue(String textureValue); AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstract boolean takeItem(Player ... |
@Test public void testLocation() { Location loc1 = new Location(mockWorld, 1, 2, 3); Location loc2 = new Location(mockWorld, 4, 5, 6, 0.5F, 0.6F); Mockito.when(mockWorld.getName()).thenReturn("test"); Assert.assertEquals(loc1, fn.location("test", 1, 2, 3)); Mockito.when(mockWorld.getName()).thenReturn("test2"); Assert.... | public Location location(String world, double x, double y, double z) { return location(world, x, y, z, 0.0, 0.0); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Location location(String world, double x, double y, double z) { return location(world, x, y, z, 0.0, 0.0); } } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Location location(String world, double x, double y, double z) { return location(world, x, y, z, 0.0, 0.0); } AbstractCommonFunctions(TriggerReactorCore plugin); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Location location(String world, double x, double y, double z) { return location(world, x, y, z, 0.0, 0.0); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(Stri... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Location location(String world, double x, double y, double z) { return location(world, x, y, z, 0.0, 0.0); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(Stri... |
@Test public void migrate() { IConfigSource mockSource = mock(IConfigSource.class); FileConfiguration mockConfig = YamlConfiguration.loadConfiguration(new StringReader("" + "Mysql:\n" + " Enable: false\n" + " Address: 127.0.0.1:3306\n" + " DbName: TriggerReactor\n" + " UserName: root\n" + " Password: '1234'\n" + " Deep... | @Override public void migrate(IConfigSource current) { traversal(null, oldConfig.getValues(false), current::put); if (oldFile.exists()) oldFile.renameTo(new File(oldFile.getParentFile(), "config.yml.bak")); } | BukkitMigrationHelper implements IMigrationHelper { @Override public void migrate(IConfigSource current) { traversal(null, oldConfig.getValues(false), current::put); if (oldFile.exists()) oldFile.renameTo(new File(oldFile.getParentFile(), "config.yml.bak")); } } | BukkitMigrationHelper implements IMigrationHelper { @Override public void migrate(IConfigSource current) { traversal(null, oldConfig.getValues(false), current::put); if (oldFile.exists()) oldFile.renameTo(new File(oldFile.getParentFile(), "config.yml.bak")); } BukkitMigrationHelper(FileConfiguration oldConfig, File old... | BukkitMigrationHelper implements IMigrationHelper { @Override public void migrate(IConfigSource current) { traversal(null, oldConfig.getValues(false), current::put); if (oldFile.exists()) oldFile.renameTo(new File(oldFile.getParentFile(), "config.yml.bak")); } BukkitMigrationHelper(FileConfiguration oldConfig, File old... | BukkitMigrationHelper implements IMigrationHelper { @Override public void migrate(IConfigSource current) { traversal(null, oldConfig.getValues(false), current::put); if (oldFile.exists()) oldFile.renameTo(new File(oldFile.getParentFile(), "config.yml.bak")); } BukkitMigrationHelper(FileConfiguration oldConfig, File old... |
@Test public void testTiming() { Timings.Timing timingName = Timings.getTiming("my.timing.name"); Timings.Timing timingTiming = Timings.getTiming("my.timing"); Timings.Timing timingMy = Timings.getTiming("my"); Timings.Timing root = Timings.getTiming(null); Assert.assertNotNull(timingName); Assert.assertNotNull(timingT... | public static Timing getTiming(String name) { return getTiming(root, name); } | Timings { public static Timing getTiming(String name) { return getTiming(root, name); } } | Timings { public static Timing getTiming(String name) { return getTiming(root, name); } } | Timings { public static Timing getTiming(String name) { return getTiming(root, name); } static void reset(); static Timing getTiming(String name); static void print(Timing timing, OutputStream stream); static void printAll(OutputStream stream); } | Timings { public static Timing getTiming(String name) { return getTiming(root, name); } static void reset(); static Timing getTiming(String name); static void print(Timing timing, OutputStream stream); static void printAll(OutputStream stream); static final Timing LIMBO; static boolean on; } |
@Test public void testExampleTiming() throws Exception { Timings.on = true; Timings.Timing timingExMessage = Timings.getTiming("CommandTrigger.myCmd.Executors.#MESSAGE"); Timings.Timing timingExTP = Timings.getTiming("CommandTrigger.myCmd.Executors.#TP"); Timings.Timing timingPhPlayerName = Timings.getTiming("CommandTr... | public static Timing getTiming(String name) { return getTiming(root, name); } | Timings { public static Timing getTiming(String name) { return getTiming(root, name); } } | Timings { public static Timing getTiming(String name) { return getTiming(root, name); } } | Timings { public static Timing getTiming(String name) { return getTiming(root, name); } static void reset(); static Timing getTiming(String name); static void print(Timing timing, OutputStream stream); static void printAll(OutputStream stream); } | Timings { public static Timing getTiming(String name) { return getTiming(root, name); } static void reset(); static Timing getTiming(String name); static void print(Timing timing, OutputStream stream); static void printAll(OutputStream stream); static final Timing LIMBO; static boolean on; } |
@Test public void testRandoms() throws Exception { for (int i = 0; i < trials; i++) { double value = fn.random(1.0); assertTrue(0.0 <= value && value < 1.0); value = fn.random(0.0, 1.0); assertTrue(0.0 <= value && value < 1.0); value = fn.random(1.0F); assertTrue(0.0 <= value && value < 1.0); value = fn.random(0.0F, 1.... | public int random(int end) { return rand.nextInt(end); } | CommonFunctions implements SelfReference { public int random(int end) { return rand.nextInt(end); } } | CommonFunctions implements SelfReference { public int random(int end) { return rand.nextInt(end); } } | CommonFunctions implements SelfReference { public int random(int end) { return rand.nextInt(end); } int random(int end); float random(float end); double random(double end); long random(long end); int random(int start, int end); float random(float start, float end); double random(double start, double end); long random(... | CommonFunctions implements SelfReference { public int random(int end) { return rand.nextInt(end); } int random(int end); float random(float end); double random(double end); long random(long end); int random(int start, int end); float random(float start, float end); double random(double start, double end); long random(... |
@Test public void testSLocation() throws Exception { assertEquals(fn.slocation("merp", 1, 2, 3), new SimpleLocation("merp", 1, 2, 3)); } | public SimpleLocation slocation(String world, int x, int y, int z) { if (world == null) { throw new IllegalArgumentException("world cannot be null"); } return new SimpleLocation(world, x, y, z); } | CommonFunctions implements SelfReference { public SimpleLocation slocation(String world, int x, int y, int z) { if (world == null) { throw new IllegalArgumentException("world cannot be null"); } return new SimpleLocation(world, x, y, z); } } | CommonFunctions implements SelfReference { public SimpleLocation slocation(String world, int x, int y, int z) { if (world == null) { throw new IllegalArgumentException("world cannot be null"); } return new SimpleLocation(world, x, y, z); } } | CommonFunctions implements SelfReference { public SimpleLocation slocation(String world, int x, int y, int z) { if (world == null) { throw new IllegalArgumentException("world cannot be null"); } return new SimpleLocation(world, x, y, z); } int random(int end); float random(float end); double random(double end); long r... | CommonFunctions implements SelfReference { public SimpleLocation slocation(String world, int x, int y, int z) { if (world == null) { throw new IllegalArgumentException("world cannot be null"); } return new SimpleLocation(world, x, y, z); } int random(int end); float random(float end); double random(double end); long r... |
@Test public void testConstructor() throws Exception { ExampleClass e = (ExampleClass) fn.newInstance(example, 1); assertEquals(0, e.marker); e = (ExampleClass) fn.newInstance(example, new Double(1.1)); assertEquals(2, e.marker); File file = null; try { file = (File) fn.newInstance("java.io.File", "test.txt"); FileWrit... | public Object newInstance(String className, Object... args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalArgumentException, InvocationTargetException { try { Class<?> clazz = Class.forName(className); List<Constructor<?>> validConstructors = new ArrayList<>(); for (Constructor<?>... | CommonFunctions implements SelfReference { public Object newInstance(String className, Object... args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalArgumentException, InvocationTargetException { try { Class<?> clazz = Class.forName(className); List<Constructor<?>> validConstructo... | CommonFunctions implements SelfReference { public Object newInstance(String className, Object... args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalArgumentException, InvocationTargetException { try { Class<?> clazz = Class.forName(className); List<Constructor<?>> validConstructo... | CommonFunctions implements SelfReference { public Object newInstance(String className, Object... args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalArgumentException, InvocationTargetException { try { Class<?> clazz = Class.forName(className); List<Constructor<?>> validConstructo... | CommonFunctions implements SelfReference { public Object newInstance(String className, Object... args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalArgumentException, InvocationTargetException { try { Class<?> clazz = Class.forName(className); List<Constructor<?>> validConstructo... |
@Test public void testReload() { Mockito.when(mockFile.exists()).thenReturn(true); manager.reload(); Map<String, Object> cache = Whitebox.getInternalState(manager, "cache"); List<Integer> list = new ArrayList<>(); list.add(1); list.add(2); list.add(3); Assert.assertEquals(list, cache.get("array")); Assert.assertEquals(... | @Override public void reload() { ensureFile(); synchronized (file) { try (Reader fr = this.readerFactory.apply(file)) { synchronized (cache) { cache.clear(); Map<String, Object> loaded = gson.fromJson(fr, new TypeToken<Map<String, Object>>() { }.getType()); if (loaded != null) { cache.putAll(loaded); } } } catch (IOExc... | GsonConfigSource implements IConfigSource { @Override public void reload() { ensureFile(); synchronized (file) { try (Reader fr = this.readerFactory.apply(file)) { synchronized (cache) { cache.clear(); Map<String, Object> loaded = gson.fromJson(fr, new TypeToken<Map<String, Object>>() { }.getType()); if (loaded != null... | GsonConfigSource implements IConfigSource { @Override public void reload() { ensureFile(); synchronized (file) { try (Reader fr = this.readerFactory.apply(file)) { synchronized (cache) { cache.clear(); Map<String, Object> loaded = gson.fromJson(fr, new TypeToken<Map<String, Object>>() { }.getType()); if (loaded != null... | GsonConfigSource implements IConfigSource { @Override public void reload() { ensureFile(); synchronized (file) { try (Reader fr = this.readerFactory.apply(file)) { synchronized (cache) { cache.clear(); Map<String, Object> loaded = gson.fromJson(fr, new TypeToken<Map<String, Object>>() { }.getType()); if (loaded != null... | GsonConfigSource implements IConfigSource { @Override public void reload() { ensureFile(); synchronized (file) { try (Reader fr = this.readerFactory.apply(file)) { synchronized (cache) { cache.clear(); Map<String, Object> loaded = gson.fromJson(fr, new TypeToken<Map<String, Object>>() { }.getType()); if (loaded != null... |
@Test public void testSaveAll() { Mockito.when(mockFile.exists()).thenReturn(true); Map<String, Object> cache = Whitebox.getInternalState(manager, "cache"); cache.put("array2", new int[]{4, 5, 6}); cache.put("boolean2", false); cache.put("color2", "#123b9cc"); cache.put("null", null); cache.put("number2", 456); cache.p... | @Override public void saveAll() { ensureFile(); synchronized (file) { cacheToFile(); } } | GsonConfigSource implements IConfigSource { @Override public void saveAll() { ensureFile(); synchronized (file) { cacheToFile(); } } } | GsonConfigSource implements IConfigSource { @Override public void saveAll() { ensureFile(); synchronized (file) { cacheToFile(); } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writerFactory); } | GsonConfigSource implements IConfigSource { @Override public void saveAll() { ensureFile(); synchronized (file) { cacheToFile(); } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writerFactory); @Override void reload(); @Override void disable(); @... | GsonConfigSource implements IConfigSource { @Override public void saveAll() { ensureFile(); synchronized (file) { cacheToFile(); } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writerFactory); @Override void reload(); @Override void disable(); @... |
@Test public void testGet() { Mockito.when(mockFile.exists()).thenReturn(true); manager.reload(); Assert.assertTrue(manager.get("object").orElse(null) instanceof Map); Assert.assertEquals("b", manager.get("object.a").orElse(null)); Assert.assertEquals("d", manager.get("object.c").orElse(null)); Assert.assertEquals("f",... | private <T> T get(Map<String, Object> map, String[] path, Class<T> asType) { for (int i = 0; i < path.length; i++) { String key = path[i]; Object value = map.get(key); if (i == path.length - 1) { return asType.cast(value); } else if (value instanceof Map) { map = (Map<String, Object>) value; } else { return null; } } r... | GsonConfigSource implements IConfigSource { private <T> T get(Map<String, Object> map, String[] path, Class<T> asType) { for (int i = 0; i < path.length; i++) { String key = path[i]; Object value = map.get(key); if (i == path.length - 1) { return asType.cast(value); } else if (value instanceof Map) { map = (Map<String,... | GsonConfigSource implements IConfigSource { private <T> T get(Map<String, Object> map, String[] path, Class<T> asType) { for (int i = 0; i < path.length; i++) { String key = path[i]; Object value = map.get(key); if (i == path.length - 1) { return asType.cast(value); } else if (value instanceof Map) { map = (Map<String,... | GsonConfigSource implements IConfigSource { private <T> T get(Map<String, Object> map, String[] path, Class<T> asType) { for (int i = 0; i < path.length; i++) { String key = path[i]; Object value = map.get(key); if (i == path.length - 1) { return asType.cast(value); } else if (value instanceof Map) { map = (Map<String,... | GsonConfigSource implements IConfigSource { private <T> T get(Map<String, Object> map, String[] path, Class<T> asType) { for (int i = 0; i < path.length; i++) { String key = path[i]; Object value = map.get(key); if (i == path.length - 1) { return asType.cast(value); } else if (value instanceof Map) { map = (Map<String,... |
@Test public void testPut() { Mockito.when(mockFile.exists()).thenReturn(true); manager.put("some.data.value", "abc"); manager.put("some.data.value2", 123); manager.put("some.data.value3", false); Assert.assertEquals("abc", manager.get("some.data.value").orElse(null)); Assert.assertEquals(123, manager.get("some.data.va... | private void put(Map<String, Object> map, String[] path, Object value) { for (int i = 0; i < path.length; i++) { String key = path[i]; if (i == path.length - 1) { map.put(key, value); } else { Object previous = map.computeIfAbsent(key, (k) -> new HashMap<>()); if (!(previous instanceof Map)) throw new RuntimeException(... | GsonConfigSource implements IConfigSource { private void put(Map<String, Object> map, String[] path, Object value) { for (int i = 0; i < path.length; i++) { String key = path[i]; if (i == path.length - 1) { map.put(key, value); } else { Object previous = map.computeIfAbsent(key, (k) -> new HashMap<>()); if (!(previous ... | GsonConfigSource implements IConfigSource { private void put(Map<String, Object> map, String[] path, Object value) { for (int i = 0; i < path.length; i++) { String key = path[i]; if (i == path.length - 1) { map.put(key, value); } else { Object previous = map.computeIfAbsent(key, (k) -> new HashMap<>()); if (!(previous ... | GsonConfigSource implements IConfigSource { private void put(Map<String, Object> map, String[] path, Object value) { for (int i = 0; i < path.length; i++) { String key = path[i]; if (i == path.length - 1) { map.put(key, value); } else { Object previous = map.computeIfAbsent(key, (k) -> new HashMap<>()); if (!(previous ... | GsonConfigSource implements IConfigSource { private void put(Map<String, Object> map, String[] path, Object value) { for (int i = 0; i < path.length; i++) { String key = path[i]; if (i == path.length - 1) { map.put(key, value); } else { Object previous = map.computeIfAbsent(key, (k) -> new HashMap<>()); if (!(previous ... |
@Test public void testBlock() { Block mockBlock = Mockito.mock(Block.class); Mockito.when(mockWorld.getBlockAt(Mockito.any(Location.class))) .thenReturn(mockBlock); Assert.assertEquals(mockBlock, fn.block("test", 1, 2, 3)); } | public Block block(String world, int x, int y, int z) { return location(world, x, y, z).getBlock(); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Block block(String world, int x, int y, int z) { return location(world, x, y, z).getBlock(); } } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Block block(String world, int x, int y, int z) { return location(world, x, y, z).getBlock(); } AbstractCommonFunctions(TriggerReactorCore plugin); } | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Block block(String world, int x, int y, int z) { return location(world, x, y, z).getBlock(); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Dep... | AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Block block(String world, int x, int y, int z) { return location(world, x, y, z).getBlock(); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Dep... |
@Test public void testKeys() { Mockito.when(mockFile.exists()).thenReturn(true); manager.reload(); Set<String> expected = new HashSet<>(); expected.add("array"); expected.add("boolean"); expected.add("color"); expected.add("null"); expected.add("number"); expected.add("fnumber"); expected.add("object"); expected.add("s... | @Override public Set<String> keys() { synchronized (cache) { return new HashSet<>(cache.keySet()); } } | GsonConfigSource implements IConfigSource { @Override public Set<String> keys() { synchronized (cache) { return new HashSet<>(cache.keySet()); } } } | GsonConfigSource implements IConfigSource { @Override public Set<String> keys() { synchronized (cache) { return new HashSet<>(cache.keySet()); } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writerFactory); } | GsonConfigSource implements IConfigSource { @Override public Set<String> keys() { synchronized (cache) { return new HashSet<>(cache.keySet()); } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writerFactory); @Override void reload(); @Override voi... | GsonConfigSource implements IConfigSource { @Override public Set<String> keys() { synchronized (cache) { return new HashSet<>(cache.keySet()); } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writerFactory); @Override void reload(); @Override voi... |
@Test public void testIsSection() { Mockito.when(mockFile.exists()).thenReturn(true); manager.reload(); Assert.assertFalse(manager.isSection("array")); Assert.assertFalse(manager.isSection("boolean")); Assert.assertFalse(manager.isSection("color")); Assert.assertFalse(manager.isSection("null")); Assert.assertFalse(mana... | @Override public boolean isSection(String key) { synchronized (cache) { return get(cache, IConfigSource.toPath(key), Object.class) instanceof Map; } } | GsonConfigSource implements IConfigSource { @Override public boolean isSection(String key) { synchronized (cache) { return get(cache, IConfigSource.toPath(key), Object.class) instanceof Map; } } } | GsonConfigSource implements IConfigSource { @Override public boolean isSection(String key) { synchronized (cache) { return get(cache, IConfigSource.toPath(key), Object.class) instanceof Map; } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writer... | GsonConfigSource implements IConfigSource { @Override public boolean isSection(String key) { synchronized (cache) { return get(cache, IConfigSource.toPath(key), Object.class) instanceof Map; } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writer... | GsonConfigSource implements IConfigSource { @Override public boolean isSection(String key) { synchronized (cache) { return get(cache, IConfigSource.toPath(key), Object.class) instanceof Map; } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writer... |
@Test public void testGetToken() throws Exception { Charset charset = StandardCharsets.UTF_8; String text = "#MESSAGE (1+(4/2.0)/3*4-(2/(3*-4)) >= 0)\n" + "#MESSAGE \"text\" \"test\"\n"; Lexer lexer = new Lexer(text, charset); testToken(lexer, Type.ID, "#MESSAGE"); testToken(lexer, Type.OPERATOR, "("); testToken(lexer,... | public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return readId(); ... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... |
@Test public void testEscapeCharacter2() throws Exception { Charset charset = StandardCharsets.UTF_8; String text = "#MESSAGE \"The cost is \\$100\""; Lexer lexer = new Lexer(text, charset); assertEquals(new Token(Type.ID, "#MESSAGE"), lexer.getToken()); assertEquals(new Token(Type.STRING, "The cost is $100"), lexer.ge... | public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return readId(); ... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... |
@Test public void testImportWithUnderscore() throws Exception{ Charset charset = StandardCharsets.UTF_8; String text; Lexer lexer; text = "IMPORT net.md_5.bungee.api.chat.ComponentBuilder"; lexer = new Lexer(text, charset); assertEquals(new Token(Type.IMPORT, "net.md_5.bungee.api.chat.ComponentBuilder"), lexer.getToken... | public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return readId(); ... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... | Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... |
@Test public void testParse() throws IOException, LexerException, ParserException { Charset charset = Charset.forName("UTF-8"); String text = "#MESSAGE (1+(4/2.0)/3*4-(2/(3*-4)) >= 0)\n" + "#MESSAGE \"text\"\n"; Lexer lexer = new Lexer(text, charset); Parser parser = new Parser(lexer); Node root = parser.parse(); Queue... | public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren().add(stat... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... |
@Test public void testParam() throws IOException, LexerException, ParserException { Charset charset = Charset.forName("UTF-8"); String text = "#SOUND player.getLocation() \"LEVEL_UP\" 1.0 1.0"; Lexer lexer = new Lexer(text, charset); Parser parser = new Parser(lexer); Node root = parser.parse(); Queue<Node> queue = new... | public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren().add(stat... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... |
@Test public void testFor() throws Exception { Charset charset = Charset.forName("UTF-8"); String text = "" + "FOR i = 0:10;" + " #MESSAGE \"test i=\"+i;" + "ENDFOR;"; Lexer lexer = new Lexer(text, charset); Parser parser = new Parser(lexer); Node root = parser.parse(); Queue<Node> queue = new LinkedList<Node>(); seria... | public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren().add(stat... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... |
@Test public void testNegation() throws Exception { Charset charset = Charset.forName("UTF-8"); String text = "" + "IF !(true && false && true || 2 < 1 && 1 < 2)\n" + " #MESSAGE \"test i=\"+i\n" + "ENDIF\n"; Lexer lexer = new Lexer(text, charset); Parser parser = new Parser(lexer); Node root = parser.parse(); Queue<Nod... | public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren().add(stat... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... |
@Test public void testPlaceholder() throws Exception { Charset charset = Charset.forName("UTF-8"); String text = "" + "x = 10;" + "#MESSAGE $placeholdertest:0:x:5:true;"; Lexer lexer = new Lexer(text, charset); Parser parser = new Parser(lexer); Node root = parser.parse(); Queue<Node> queue = new LinkedList<Node>(); se... | public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren().add(stat... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.