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


Java PolymorphicTypeResolver类代码示例

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


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

示例1: getMeshRootVertex

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
/**
 * Return the mesh root vertex.
 * 
 * @return
 */
public static Vertex getMeshRootVertex(TransactionalGraph graph) {
	Iterator<Vertex> it = graph.getVertices("@class", MESH_ROOT_TYPE).iterator();
	if (it.hasNext()) {
		return it.next();
	} else {
		Iterator<Vertex> itLegacy = graph.getVertices(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY, MESH_ROOT_LEGACY_TYPE).iterator();
		if (itLegacy.hasNext()) {
			return itLegacy.next();
		} else {
			// Legacy index less handling
			for (Vertex vertex : graph.getVertices()) {
				String fermaType = vertex.getProperty("ferma_type");
				if (fermaType != null && fermaType.endsWith(MESH_ROOT_TYPE)) {
					return vertex;
				}
			}
			return null;
		}
	}
}
 
开发者ID:gentics,项目名称:mesh,代码行数:26,代码来源:MeshGraphHelper.java

示例2: testCreateMultithreaded

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
@Ignore("Disabled since test is unstable - CL-246")
@Override
public void testCreateMultithreaded() throws Exception {
	int nJobs = 100;
	long nProjectsBefore = meshRoot().getProjectRoot().computeCount();

	Set<MeshResponse<?>> set = new HashSet<>();
	for (int i = 0; i < nJobs; i++) {
		ProjectCreateRequest request = new ProjectCreateRequest();
		request.setName("test12345_" + i);
		request.setSchema(new SchemaReferenceImpl().setName("folder"));
		set.add(client().createProject(request).invoke());
	}
	validateCreation(set, null);

	try (Tx tx = tx()) {
		long n = StreamSupport.stream(tx.getGraph().getVertices(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY, ProjectImpl.class.getName())
				.spliterator(), true).count();
		long nProjectsAfter = meshRoot().getProjectRoot().computeCount();
		assertEquals(nProjectsBefore + nJobs, nProjectsAfter);
		assertEquals(nProjectsBefore + nJobs, n);
	}
}
 
开发者ID:gentics,项目名称:mesh,代码行数:25,代码来源:ProjectEndpointTest.java

示例3: DelegatingFramedGraph

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
/**
 * Construct a framed graph with the specified typeResolution and annotation support
 *
 * @param delegate
 *            The graph to wrap.
 * @param typeResolution
 * 			  True if type resolution is to be automatically handled by default, false causes explicit typing by
 * @param annotationsSupported
 * 			  True if annotated classes will be supported, false otherwise.
 */
public DelegatingFramedGraph(final G delegate, final boolean typeResolution, final boolean annotationsSupported) {
    this.delegate = delegate;

    final ReflectionCache reflections = new ReflectionCache();
    if (typeResolution) {
        this.defaultResolver = new PolymorphicTypeResolver(reflections);
        this.untypedResolver = new UntypedTypeResolver();
    }
    else {
        this.defaultResolver = new UntypedTypeResolver();
        this.untypedResolver = this.defaultResolver;
    }
    if (annotationsSupported)
        this.builder = new AnnotationFrameFactory(reflections);
    else
        this.builder = new DefaultFrameFactory();
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:28,代码来源:DelegatingFramedGraph.java

示例4: testCustomHandlers

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
public void testCustomHandlers() {
    MethodHandler custom = Mockito.mock(AbstractMethodHandler.class, Mockito.CALLS_REAL_METHODS);
    Class<? extends Annotation> annotation = Adjacency.class;
    custom = Mockito.when(custom.getAnnotationType()).then(inv -> annotation).getMock();
    custom = Mockito
            .when(custom.processMethod(Mockito.any(), Mockito.any(), Mockito.any()))
            .thenAnswer(inv -> inv.getArgumentAt(0, DynamicType.Builder.class))
            .getMock();
    AbstractAnnotationFrameFactory frameFactory = new AbstractAnnotationFrameFactory(new ReflectionCache(), Collections.singleton(custom)) {
    };
    DelegatingFramedGraph framedGraph = new DelegatingFramedGraph(fg.getBaseGraph(), frameFactory, new PolymorphicTypeResolver());
    framedGraph.addFramedVertex(God.class);
    Mockito.verify(custom, Mockito.atLeast(0)).getAnnotationType();
    Mockito.verify(custom, Mockito.atLeastOnce()).processMethod(Mockito.any(), Mockito.any(), Mockito.any());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:17,代码来源:AnnotationFrameFactoryTest.java

示例5: testCustomTypeKey

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
public void testCustomTypeKey() {
    final Graph g = TinkerGraph.open();
    final ReflectionCache cache = new ReflectionCache(TEST_TYPES);
    final FramedGraph fg = new DelegatingFramedGraph(g, new AnnotationFrameFactory(cache), new PolymorphicTypeResolver(cache, CUSTOM_TYPE_KEY));

    final Person p1 = fg.addFramedVertex(Programmer.DEFAULT_INITIALIZER);
    p1.setName("Bryn");

    final Person p2 = fg.addFramedVertex(Person.DEFAULT_INITIALIZER);
    p2.setName("Julia");

    final Person bryn = fg.traverse(
        input -> input.V().has("name", "Bryn")).next(Person.class);
    final Person julia = fg.traverse(
        input -> input.V().has("name", "Julia")).next(Person.class);

    Assert.assertEquals(Programmer.class, bryn.getClass());
    Assert.assertEquals(Person.class, julia.getClass());

    Assert.assertNotNull(bryn.getElement().property(CUSTOM_TYPE_KEY).value());
    Assert.assertFalse(bryn.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
    Assert.assertNotNull(julia.getElement().property(CUSTOM_TYPE_KEY).value());
    Assert.assertFalse(julia.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:26,代码来源:PolymorphicTypeResolverTest.java

示例6: testCustomTypeKeyByClass

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
public void testCustomTypeKeyByClass() {
    final Graph g = TinkerGraph.open();
    final ReflectionCache cache = new ReflectionCache(TEST_TYPES);
    final FramedGraph fg = new DelegatingFramedGraph(g, new AnnotationFrameFactory(cache), new PolymorphicTypeResolver(cache, CUSTOM_TYPE_KEY));

    final Person p1 = fg.addFramedVertex(Programmer.class);
    p1.setName("Bryn");

    final Person p2 = fg.addFramedVertex(Person.class);
    p2.setName("Julia");

    final Person bryn = fg.traverse(input -> input.V().has("name", "Bryn")).next(Person.class);
    final Person julia = fg.traverse(input -> input.V().has("name", "Julia")).next(Person.class);

    Assert.assertEquals(Programmer.class, bryn.getClass());
    Assert.assertEquals(Person.class, julia.getClass());

    Assert.assertNotNull(bryn.getElement().property(CUSTOM_TYPE_KEY).value());
    Assert.assertFalse(bryn.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
    Assert.assertNotNull(julia.getElement().property(CUSTOM_TYPE_KEY).value());
    Assert.assertFalse(julia.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:24,代码来源:PolymorphicTypeResolverTest.java

示例7: testCustomTypeKeyExplicit

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
public void testCustomTypeKeyExplicit() {
    final Graph g = TinkerGraph.open();
    final ReflectionCache cache = new ReflectionCache(TEST_TYPES);
    final FramedGraph fg = new DelegatingFramedGraph(g, new AnnotationFrameFactory(cache), new PolymorphicTypeResolver(cache, CUSTOM_TYPE_KEY));

    final Person p1 = fg.addFramedVertexExplicit(Programmer.DEFAULT_INITIALIZER);
    p1.setName("Bryn");

    final Person p2 = fg.addFramedVertexExplicit(Person.DEFAULT_INITIALIZER);
    p2.setName("Julia");

    final Person bryn = fg.traverse(input -> input.V().has("name", "Bryn")).next(Person.class);
    final Person julia = fg.traverse(input -> input.V().has("name", "Julia")).next(Person.class);

    Assert.assertEquals(Person.class, bryn.getClass());
    Assert.assertEquals(Person.class, julia.getClass());

    Assert.assertFalse(bryn.getElement().property(CUSTOM_TYPE_KEY).isPresent());
    Assert.assertFalse(bryn.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
    Assert.assertFalse(julia.getElement().property(CUSTOM_TYPE_KEY).isPresent());
    Assert.assertFalse(julia.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:24,代码来源:PolymorphicTypeResolverTest.java

示例8: testCustomTypeKeyExplicitByClass

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
public void testCustomTypeKeyExplicitByClass() {
    final Graph g = TinkerGraph.open();
    final ReflectionCache cache = new ReflectionCache(TEST_TYPES);
    final FramedGraph fg = new DelegatingFramedGraph(g, new AnnotationFrameFactory(cache), new PolymorphicTypeResolver(cache, CUSTOM_TYPE_KEY));

    final Person p1 = fg.addFramedVertexExplicit(Programmer.class);
    p1.setName("Bryn");

    final Person p2 = fg.addFramedVertexExplicit(Person.class);
    p2.setName("Julia");

    final Person bryn = fg.traverse(input -> input.V().has("name", "Bryn")).next(Person.class);
    final Person julia = fg.traverse(input -> input.V().has("name", "Julia")).next(Person.class);

    Assert.assertEquals(Person.class, bryn.getClass());
    Assert.assertEquals(Person.class, julia.getClass());

    Assert.assertFalse(bryn.getElement().property(CUSTOM_TYPE_KEY).isPresent());
    Assert.assertFalse(bryn.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
    Assert.assertFalse(julia.getElement().property(CUSTOM_TYPE_KEY).isPresent());
    Assert.assertFalse(julia.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:24,代码来源:PolymorphicTypeResolverTest.java

示例9: testJavaTyping

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
public void testJavaTyping() {
    final Graph g = TinkerGraph.open();
    final FramedGraph fg = new DelegatingFramedGraph(g, true, false);

    final Person p1 = fg.addFramedVertex(Programmer.DEFAULT_INITIALIZER);
    p1.setName("Bryn");

    final Person p2 = fg.addFramedVertex(Person.DEFAULT_INITIALIZER);
    p2.setName("Julia");

    final Person bryn = fg.traverse(
        input -> input.V().has("name", "Bryn")).next(Person.class);
    final Person julia = fg.traverse(
        input -> input.V().has("name", "Julia")).next(Person.class);

    Assert.assertEquals(Programmer.class, bryn.getClass());
    Assert.assertEquals(Person.class, julia.getClass());

    Assert.assertNotNull(bryn.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).value());
    Assert.assertNotNull(julia.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).value());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:23,代码来源:FramedGraphTest.java

示例10: testJavaTypingByClass

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
public void testJavaTypingByClass() {
    final Graph g = TinkerGraph.open();
    final FramedGraph fg = new DelegatingFramedGraph(g, true, false);

    final Person p1 = fg.addFramedVertex(Programmer.class);
    p1.setName("Bryn");

    final Person p2 = fg.addFramedVertex(Person.class);
    p2.setName("Julia");

    final Person bryn = fg.traverse(
        input -> input.V().has("name", "Bryn")).next(Person.class);
    final Person julia = fg.traverse(
        input -> input.V().has("name", "Julia")).next(Person.class);

    Assert.assertEquals(Programmer.class, bryn.getClass());
    Assert.assertEquals(Person.class, julia.getClass());

    Assert.assertNotNull(bryn.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).value());
    Assert.assertNotNull(julia.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).value());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:23,代码来源:FramedGraphTest.java

示例11: testJavaTypingAddExplicit

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
public void testJavaTypingAddExplicit() {
    final Graph g = TinkerGraph.open();
    final FramedGraph fg = new DelegatingFramedGraph(g, true, false);

    final Person p1 = fg.addFramedVertexExplicit(Programmer.DEFAULT_INITIALIZER);
    p1.setName("Bryn");

    final Person p2 = fg.addFramedVertexExplicit(Person.DEFAULT_INITIALIZER);
    p2.setName("Julia");

    final Person bryn = fg.traverse(
        input -> input.V().has("name", "Bryn")).next(Person.class);
    final Person julia = fg.traverse(
        input -> input.V().has("name", "Julia")).next(Person.class);

    Assert.assertEquals(Person.class, bryn.getClass());
    Assert.assertEquals(Person.class, julia.getClass());

    Assert.assertFalse(bryn.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
    Assert.assertFalse(julia.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:23,代码来源:FramedGraphTest.java

示例12: testJavaTypingAddExplicitByClass

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
public void testJavaTypingAddExplicitByClass() {
    final Graph g = TinkerGraph.open();
    final FramedGraph fg = new DelegatingFramedGraph(g, true, false);

    final Person p1 = fg.addFramedVertexExplicit(Programmer.class);
    p1.setName("Bryn");

    final Person p2 = fg.addFramedVertexExplicit(Person.class);
    p2.setName("Julia");

    final Person bryn = fg.traverse(
        input -> input.V().has("name", "Bryn")).next(Person.class);
    final Person julia = fg.traverse(
        input -> input.V().has("name", "Julia")).next(Person.class);

    Assert.assertEquals(Person.class, bryn.getClass());
    Assert.assertEquals(Person.class, julia.getClass());

    Assert.assertFalse(bryn.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
    Assert.assertFalse(julia.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).isPresent());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:23,代码来源:FramedGraphTest.java

示例13: testJavaTypingNextExplicit

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
public void testJavaTypingNextExplicit() {
    final Graph g = TinkerGraph.open();
    final FramedGraph fg = new DelegatingFramedGraph(g, true, false);

    final Person p1 = fg.addFramedVertex(Programmer.DEFAULT_INITIALIZER);
    p1.setName("Bryn");

    final Person p2 = fg.addFramedVertex(Person.DEFAULT_INITIALIZER);
    p2.setName("Julia");

    final Person bryn = fg.traverse(
        input -> input.V().has("name", "Bryn")).nextExplicit(Person.class);
    final Person julia = fg.traverse(
        input -> input.V().has("name", "Julia")).nextExplicit(Person.class);

    Assert.assertEquals(Person.class, bryn.getClass());
    Assert.assertEquals(Person.class, julia.getClass());

    Assert.assertNotNull(bryn.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).value());
    Assert.assertNotNull(julia.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).value());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:23,代码来源:FramedGraphTest.java

示例14: testJavaTypingNextExplicitByClass

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Test
public void testJavaTypingNextExplicitByClass() {
    final Graph g = TinkerGraph.open();
    final FramedGraph fg = new DelegatingFramedGraph(g, true, false);

    final Person p1 = fg.addFramedVertex(Programmer.class);
    p1.setName("Bryn");

    final Person p2 = fg.addFramedVertex(Person.class);
    p2.setName("Julia");

    final Person bryn = fg.traverse(
        input -> input.V().has("name", "Bryn")).nextExplicit(Person.class);
    final Person julia = fg.traverse(
        input -> input.V().has("name", "Julia")).nextExplicit(Person.class);

    Assert.assertEquals(Person.class, bryn.getClass());
    Assert.assertEquals(Person.class, julia.getClass());

    Assert.assertNotNull(bryn.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).value());
    Assert.assertNotNull(julia.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).value());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:23,代码来源:FramedGraphTest.java

示例15: apply

import com.syncleus.ferma.typeresolvers.PolymorphicTypeResolver; //导入依赖的package包/类
@Override
public void apply() {

	// Iterate over all field container
	Iterable<Vertex> vertices = getGraph().getVertices(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY, "NodeGraphFieldContainerImpl");
	for (Vertex container : vertices) {
		migrateContainer(container);
	}
}
 
开发者ID:gentics,项目名称:mesh,代码行数:10,代码来源:RemoveBogusWebrootProperty.java


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