当前位置: 首页>>代码示例>>Java>>正文


Java Nothing类代码示例

本文整理汇总了Java中org.aikodi.rejuse.action.Nothing的典型用法代码示例。如果您正苦于以下问题:Java Nothing类的具体用法?Java Nothing怎么用?Java Nothing使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Nothing类属于org.aikodi.rejuse.action包,在下文中一共展示了Nothing类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNodes

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
/**
 * Return the leaf nodes of this graph.
 */
/*@
  @ post \result != null;
  @ // No nodes that are not in this graph.
  @ post getNodes().containsAll(\result);
  @ post (\forall Object o; \result.contains(o); o instanceof Node);
  @ post (\forall Node node; getNodes().contains(node);
  @         \result.contains(node) == node.isLeaf());
  @*/
public Set<Node<V>> getLeaves() {
	Set<Node<V>> result = nodes();
	new Predicate<Node<V>,Nothing>() {
		public boolean eval(Node<V> o) {
			return o.isLeaf();
		}
	}.filter(result);
	return result;
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:21,代码来源:Graph.java

示例2: read

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
protected void read(XMLStreamReader reader, PARENTTYPE parent, Consumer<? super TYPE, Nothing> closer) throws E, XMLStreamException {
	// Open
	String tagName = reader.getLocalName();
	TYPE currentElement;
	if (defaultConstructor != null) {
		currentElement = defaultConstructor.produce();
	} else if (constructorWithParent != null) {
		requireNotNull(parent, "The constructor for " + tagName + " expects a parent object, but received null.");
		currentElement = constructorWithParent.apply(parent, attributes(tagName, reader));
	} else if (constructorWithAttributes != null) {
		currentElement = constructorWithAttributes.apply(attributes(tagName, reader));
	} else {
		throw new IllegalStateException("No element could be constructed.");
	}

	// Content
	readChildren(reader, currentElement);

	// Close
	if (closer != null) {
		closer.accept(currentElement);
	} else if (_closerWithParent != null) {
		_closerWithParent.accept(parent, currentElement);
	}
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:26,代码来源:TreeReader.java

示例3: testSingleRootNodeFirstInputOneNode

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
@Test
public void testSingleRootNodeFirstInputOneNode() throws XMLStreamException {
	// GIVEN
	//   a tree reader that read 'a' nodes and set their names to 'A name'
	TreeReader<A, Nothing> first = TreeReader.<A, Nothing>builder()
			.open("a", () -> new A("A name"))
			.close()
			.build();
	
	// WHEN
	//   it reads the input '<a></a>'
    A output = first.read(reader("<a></a>"));
    
    // THEN
    //   the result is not null.
    assertNotNull(output);
    //   the result has name 'A name'
    assertEquals("A name", output.name());
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:20,代码来源:TestTreeReader.java

示例4: testSingleRootNodeFirstInputWrongNode

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
@Test
public void testSingleRootNodeFirstInputWrongNode() throws XMLStreamException {
	// GIVEN
	//   a tree reader that read 'a' nodes and set their names to 'A name'
	TreeReader<A, Nothing> first = TreeReader.<A, Nothing>builder()
			.open("a", () -> new A("A name"))
			.close()
			.build();

	// WHEN
	//   it reads an input that does not contain 'a' tags.
	A output = first.read(reader("<b></b>"));
	
	// THEN
	//   the output is null.
    assertNull(output);
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:18,代码来源:TestTreeReader.java

示例5: testSingleRootNodeFirstInputOneNodeWithAttribute

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
@Test
public void testSingleRootNodeFirstInputOneNodeWithAttribute() throws XMLStreamException {
	// GIVEN
	//   a tree reader that read 'a' nodes and set their names to the 
	//   'name' attribute of the tag.
	TreeReader<A, Nothing> first = TreeReader.<A, Nothing>builder()
			.open("a", n -> new A(n.attribute("name")))
			.close()
			.build();
	
	// WHEN
	//   it reads an 'a' node with name 'b'.
    A output = first.read(reader("<a name=\"b\"></a>"));
    
    // THEN
    //   the result is not null
    assertNotNull(output);
    //   the result has the attribute value of the 'name' attribute: 'b'.
    assertEquals("b", output.name());
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:21,代码来源:TestTreeReader.java

示例6: testSingleRootNodeFirstInputOneNodeWithManyAttributes

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
@Test
public void testSingleRootNodeFirstInputOneNodeWithManyAttributes() throws XMLStreamException {
	// GIVEN
	//   a tree reader that read 'a' nodes and set their names to the 
	//   'name' attribute of the tag.
	TreeReader<A, Nothing> first = TreeReader.<A, Nothing>builder()
			.open("a", n -> new A(n.attribute("name")))
			.close()
			.build();
	
	// WHEN
	//   it reads an 'a' node with name 'b'.
    A output = first.read(reader("<a firstAttribute=\"something\" name=\"b\"></a>"));
    
    // THEN
    //   the result is not null
    assertNotNull(output);
    //   the result has the attribute value of the 'name' attribute: 'b'.
    assertEquals("b", output.name());
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:21,代码来源:TestTreeReader.java

示例7: testSingleRootNodeFirstInputOneNodeWithWrongAttribute

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
@Test(expected=IllegalArgumentException.class)
public void testSingleRootNodeFirstInputOneNodeWithWrongAttribute() throws XMLStreamException {
	// GIVEN
	//   a tree reader that read 'a' nodes and set their names to the 
	//   'name' attribute of the tag.
	TreeReader<A, Nothing> first = TreeReader.<A, Nothing>builder()
			.open("a", n -> new A(n.attribute("name")))
			.close()
			.build();
	
	// WHEN
	//   it reads an 'a' node with attribute 'namee' set to 'b' .
    A output = first.read(reader("<a namee=\"b\"></a>"));
    
    // THEN
    //   the reader throws an exception
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:18,代码来源:TestTreeReader.java

示例8: testSingleRootNodeFirstWithChildInputNoDirectChild

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
@Test
public void testSingleRootNodeFirstWithChildInputNoDirectChild() throws XMLStreamException {
	// GIVEN
	//   a tree reader that reads 'a' nodes and sets their names to 'A name'.
	//   and reads child nodes 'b' and sets their names to 'bee'.
	TreeReader<A, Nothing> first = TreeReader.<A, Nothing>builder()
			.open("a", () -> new A("A name"))
				.open("b", () -> new B("bee"))
				.close((a,b) -> a.add(b))
			.close()
			.build();

	// WHEN
	//   it reads an input that does not contain 'a' tags.
	A output = first.read(reader("<a><c><b></b></c></a>"));
	
	// THEN
	//   the output is not null.
    assertNotNull(output);
    //   the output has name 'A name'
    assertEquals("A name", output.name());
    //   the output has one child b.
    assertEquals(0, output.bs().size());
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:25,代码来源:TestTreeReader.java

示例9: packagePredicate

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
protected UniversalPredicate<? super Type,Nothing> packagePredicate(AnalysisOptions options) {
	List<String> packageNames = packageNames((DependencyOptions) options);
	UniversalPredicate<? super Type,Nothing> result;
	if(packageNames.isEmpty()) {
		result = new True();
	} else {
		result = new False();
		for(final String string: packageNames) {
			result = result.or(
					new UniversalPredicate<Type,Nothing>(Type.class) {

				@Override
				public boolean uncheckedEval(Type object) {
					return new GlobPredicate(string,'.').eval(object.nearestAncestor(NamespaceDeclaration.class).namespace().fullyQualifiedName());
				}

			}).makeUniversal(Type.class);
		}
	}
	return result;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:22,代码来源:DependencyAnalysisTool.java

示例10: crossReferenceHierarchyFilter

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
protected UniversalPredicate<CrossReference,Nothing> crossReferenceHierarchyFilter(final AnalysisOptions options, final ObjectOrientedView view) throws LookupException {
	final UniversalPredicate<Type, Nothing> hierarchyPredicate = hierarchyPredicate(options, view);
	UniversalPredicate<CrossReference,LookupException> unguarded = new UniversalPredicate<CrossReference,LookupException>(CrossReference.class) {

		@Override
		public boolean uncheckedEval(CrossReference object) throws LookupException{
			Declaration element = object.getElement();
			Type t = element.lexical().nearestAncestorOrSelf(Type.class);
			if(t != null) {
				return hierarchyPredicate.eval(t);
			} else {
				return true;
			}
		}
	};
	UniversalPredicate<CrossReference, Nothing> result = unguarded.guard(true);
	return result;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:19,代码来源:DependencyAnalysisTool.java

示例11: crossReferenceTargetType

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
protected UniversalPredicate<CrossReference,Nothing> crossReferenceTargetType(final AnalysisOptions options, final ObjectOrientedView view) throws LookupException {
	final UniversalPredicate<Type, Nothing> targetPredicate = targetTypePredicate(options, view);
	UniversalPredicate<CrossReference,LookupException> unguarded = new UniversalPredicate<CrossReference,LookupException>(CrossReference.class) {

		@Override
		public boolean uncheckedEval(CrossReference object) throws LookupException{
			Declaration element = object.getElement();
			Type t = element.lexical().nearestAncestorOrSelf(Type.class);
			if(t != null) {
				return targetPredicate.eval(t);
			} else {
				return true;
			}
		}
	};
	UniversalPredicate<CrossReference, Nothing> result = unguarded.guard(true);
	return result;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:19,代码来源:DependencyAnalysisTool.java

示例12: targetTypePredicate

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
protected UniversalPredicate<Type,Nothing> targetTypePredicate(AnalysisOptions options, ObjectOrientedView view) throws LookupException {
	UniversalPredicate<Type,Nothing> filter = SOURCE_TYPE;
	List<String> ignored = ignoredTargets((DependencyOptions) options);
	for(String fqn: ignored) {
			Type type = view.findType(fqn);
			filter = filter.and(new UniversalPredicate<Type,Nothing>(Type.class) {

				@Override
				public boolean uncheckedEval(Type t) throws Nothing {
					return ! t.getFullyQualifiedName().equals(fqn);
				}
				
			});
	}
	return filter;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:17,代码来源:DependencyAnalysisTool.java

示例13: noSuperTypes

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
private PredicateSelector<? super Dependency<? super Element, ? super CrossReference, ? super Declaration>> noSuperTypes() {
  return new CheckboxPredicateSelector<Dependency<?,?,?>>(

      new UniversalPredicate<Dependency, Nothing>(Dependency.class) {

        @Override
        public boolean uncheckedEval(Dependency t) throws Nothing {
          Element target = (Element) t.target();
          Element source = (Element)t.source();
          if(source instanceof Type && target instanceof Type) {
            try {
              return ! ((Type)source).subtypeOf((Type) target);
            } catch (LookupException e) {
            }
          }
          return true;
        }
      }, "Ignore super types",true);
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:20,代码来源:JavaDependencyOptions.java

示例14: guard

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
public default Predicate<T,Nothing> guard(final boolean value) {
  return new Predicate<T, Nothing>() {
    @Override
    public boolean eval(T object) throws Nothing {
      try {
        return Predicate.this.eval(object);
      } catch(Exception e) {
        return value;
      }
    }
    
  };
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:14,代码来源:Predicate.java

示例15: guard

import org.aikodi.rejuse.action.Nothing; //导入依赖的package包/类
@Override
public UniversalPredicate<T, Nothing> guard(final boolean value) {
	return new UniversalPredicate<T, Nothing>(type()) {

	@Override
	public boolean uncheckedEval(T object) throws Nothing {
		try {
			return UniversalPredicate.this.eval(object);
		} catch(Exception e) {
			return value;
		}
	}
		
	};
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:16,代码来源:UniversalPredicate.java


注:本文中的org.aikodi.rejuse.action.Nothing类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。