public static <E> DocumentBasedAssignment create( DocumentEventRouter<? super E, E, ?> router, E container) { DocumentBasedAssignment assignment = new DocumentBasedAssignment( DocumentBasedStructuredValue.create(router, container, Serializer.STRING, Key.class)); assignment.value.addListener(assignment); return assignment; }
private static <N, E extends N> ObservableStructuredValue<Key, Integer> createTargetOn2( ValueContext<N, E> context) { return DocumentBasedStructuredValue.create(DefaultDocumentEventRouter.create(context.doc), context.container, Serializer.INTEGER, Key.class); }
private static <N, E extends N> ObservableStructuredValue<Key, Integer> createTargetOn2( ValueContext<N, E> context) { return DocumentBasedStructuredValue.create(DefaultDocumentEventRouter.create(context.doc), context.container, Serializer.INTEGER, Key.class); }
/** * Creates a document-based manifest backed by an empty document. * * @param doc the document on which to base the manifest * @precondition {@code !documentHasManifest(doc)} */ @VisibleForTesting public static <E> DocumentBasedManifest createNew( ObservableMutableDocument<? super E, E, ?> doc) { // If the precondition holds then the document must be empty. E top = DocHelper.createFirstTopLevelElement(doc, MANIFEST_TOP_TAG); DocumentEventRouter<? super E, E, ?> router = DefaultDocumentEventRouter.create(doc); return new DocumentBasedManifest( DocumentBasedManifestThread.create(router, top), DocumentBasedStructuredValue.create(router, top, Serializer.STRING, AnchorKey.class)); }
/** * Creates a document-based manifest backed by a document with existing * conversation structure. * * @param router event router for the document on which to base the manifest * @precondition {@code documentHasManifest(doc)} */ static <E> DocumentBasedManifest createOnExisting( DocumentEventRouter<? super E, E, ?> router, E top) { Preconditions.checkArgument(router.getDocument().getTagName(top).equals(MANIFEST_TOP_TAG), "Invalid manifest top tag %s", router.getDocument().getTagName(top)); return new DocumentBasedManifest( DocumentBasedManifestThread.create(router, top), DocumentBasedStructuredValue.create(router, top, Serializer.STRING, AnchorKey.class)); }