本文整理汇总了Java中org.waveprotocol.wave.model.operation.wave.NoOp类的典型用法代码示例。如果您正苦于以下问题:Java NoOp类的具体用法?Java NoOp怎么用?Java NoOp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoOp类属于org.waveprotocol.wave.model.operation.wave包,在下文中一共展示了NoOp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createWaveletOperation
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
/**
* Deserializes a wavelet-operation message.
*
* @param context operation context for the operation
* @param message operation message
* @param checkWellFormed If we should check for wellformness of deserialised DocOp
* @return an operation described by {@code message}
*/
public static WaveletOperation createWaveletOperation(WaveletOperationContext context,
ProtocolWaveletOperation message, boolean checkWellFormed)
throws InvalidInputException {
try {
if (message.hasNoOp() && message.getNoOp()) {
return new NoOp(context);
} else if (message.getAddParticipant() != null && !message.getAddParticipant().isEmpty()) {
return new AddParticipant(context, ParticipantId.of(message.getAddParticipant()));
} else if (message.getRemoveParticipant() != null
&& !message.getRemoveParticipant().isEmpty()) {
return new RemoveParticipant(context, ParticipantId.of(message.getRemoveParticipant()));
} else if (message.getMutateDocument() != null) {
return createBlipOperation(context, message, checkWellFormed);
}
throw new IllegalArgumentException("Unsupported operation: " + message);
} catch (InvalidParticipantAddress e) {
throw new RuntimeException(e);
}
}
示例2: deserialize
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
/**
* Deserialize a {@link ProtocolWaveletOperation} as a {@link WaveletOperation}.
*
* @param protobufOp protocol buffer wavelet operation to deserialize
* @return deserialized wavelet operation
*/
public static WaveletOperation deserialize(ProtocolWaveletOperation protobufOp,
WaveletOperationContext context) {
if (protobufOp.hasNoOp()) {
return new NoOp(context);
} else if (protobufOp.hasAddParticipant()) {
return new AddParticipant(context, new ParticipantId(protobufOp.getAddParticipant()));
} else if (protobufOp.hasRemoveParticipant()) {
return new RemoveParticipant(context, new ParticipantId(protobufOp.getRemoveParticipant()));
} else if (protobufOp.hasMutateDocument()) {
return new WaveletBlipOperation(protobufOp.getMutateDocument().getDocumentId(),
new BlipContentOperation(context,
deserialize(protobufOp.getMutateDocument().getDocumentOperation())));
} else {
throw new IllegalArgumentException("Unsupported operation: " + protobufOp);
}
}
示例3: deserializeWaveletOperation
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
public static WaveletOperation deserializeWaveletOperation(DBObject dbObject,
WaveletOperationContext context) throws PersistenceException {
String type = (String) dbObject.get(FIELD_TYPE);
if (type.equals(WAVELET_OP_NOOP)) {
return new NoOp(context);
} else if (type.equals(WAVELET_OP_ADD_PARTICIPANT)) {
return new AddParticipant(context,
deserializeParicipantId((DBObject) dbObject.get(FIELD_PARTICIPANT)));
} else if (type.equals(WAVELET_OP_REMOVE_PARTICIPANT)) {
return new RemoveParticipant(context,
deserializeParicipantId((DBObject) dbObject.get(FIELD_PARTICIPANT)));
} else if (type.equals(WAVELET_OP_WAVELET_BLIP_OPERATION)) {
return new WaveletBlipOperation((String) dbObject.get(FIELD_BLIPID),
deserializeBlipContentOperation((DBObject) dbObject.get(FIELD_BLIPOP), context));
} else {
throw new IllegalArgumentException("Unsupported operation: " + type);
}
}
示例4: serialize
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
/**
* Serialize a {@link WaveletOperation} as a {@link ProtocolWaveletOperation}.
*
* @param waveletOp wavelet operation to serialize
* @return serialized protocol buffer wavelet operation
*/
public ProtocolWaveletOperation serialize(WaveletOperation waveletOp) {
ProtocolWaveletOperation protobufOp = adaptor.createProtocolWaveletOperation();
if (waveletOp instanceof NoOp) {
protobufOp.setNoOp(true);
} else if (waveletOp instanceof AddParticipant) {
protobufOp.setAddParticipant(((AddParticipant) waveletOp).getParticipantId().getAddress());
} else if (waveletOp instanceof RemoveParticipant) {
protobufOp.setRemoveParticipant(((RemoveParticipant) waveletOp).getParticipantId()
.getAddress());
} else if (waveletOp instanceof WaveletBlipOperation) {
ProtocolWaveletOperation.MutateDocument mutation = adaptor.createProtocolWaveletDocumentOperation();
mutation.setDocumentId(((WaveletBlipOperation) waveletOp).getBlipId());
mutation.setDocumentOperation(serialize(((WaveletBlipOperation) waveletOp).getBlipOp()));
protobufOp.setMutateDocument(mutation);
} else {
throw new IllegalArgumentException("Unsupported operation type: " + waveletOp);
}
return protobufOp;
}
示例5: deserialize
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
/**
* Deserialize a {@link ProtocolWaveletOperation} as a
* {@link WaveletOperation}.
*
* @param protobufOp protocol buffer wavelet operation to deserialize
* @return deserialized wavelet operation
*/
public static WaveletOperation deserialize(ProtocolWaveletOperation protobufOp,
WaveletOperationContext ctx) {
if (protobufOp.hasNoOp()) {
return new NoOp(ctx);
} else if (protobufOp.hasAddParticipant()) {
return new AddParticipant(ctx, new ParticipantId(protobufOp.getAddParticipant()));
} else if (protobufOp.hasRemoveParticipant()) {
return new RemoveParticipant(ctx, new ParticipantId(protobufOp.getRemoveParticipant()));
} else if (protobufOp.hasMutateDocument()) {
return new WaveletBlipOperation(protobufOp.getMutateDocument().getDocumentId(),
new BlipContentOperation(ctx, deserialize(protobufOp.getMutateDocument()
.getDocumentOperation())));
} else {
throw new IllegalArgumentException("Unsupported operation: " + protobufOp);
}
}
示例6: serialize
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
/**
* Serialize a {@link WaveletOperation} as a {@link ProtocolWaveletOperation}.
*
* @param waveletOp wavelet operation to serialize
* @return serialized protocol buffer wavelet operation
*/
public static ProtocolWaveletOperation serialize(WaveletOperation waveletOp) {
ProtocolWaveletOperation protobufOp = ProtocolWaveletOperationJsoImpl.create();
if (waveletOp instanceof NoOp) {
protobufOp.setNoOp(true);
} else if (waveletOp instanceof AddParticipant) {
protobufOp.setAddParticipant(((AddParticipant) waveletOp).getParticipantId().getAddress());
} else if (waveletOp instanceof RemoveParticipant) {
protobufOp.setRemoveParticipant(((RemoveParticipant) waveletOp).getParticipantId()
.getAddress());
} else if (waveletOp instanceof WaveletBlipOperation) {
ProtocolWaveletOperation.MutateDocument mutation =
ProtocolWaveletOperationJsoImpl.MutateDocumentJsoImpl.create();
mutation.setDocumentId(((WaveletBlipOperation) waveletOp).getBlipId());
mutation.setDocumentOperation(serialize(((WaveletBlipOperation) waveletOp).getBlipOp()));
protobufOp.setMutateDocument(mutation);
} else {
throw new IllegalArgumentException("Unsupported operation type: " + waveletOp);
}
return protobufOp;
}
示例7: serialize
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
/**
* Serializes a wavelet operation as a {@link ProtocolWaveletOperation}.
*
* @param waveletOp wavelet operation to serialize
* @return serialized protocol buffer wavelet operation
*/
public static ProtocolWaveletOperation serialize(WaveletOperation waveletOp) {
ProtocolWaveletOperation.Builder protobufOp = ProtocolWaveletOperation.newBuilder();
if (waveletOp instanceof NoOp) {
protobufOp.setNoOp(true);
} else if (waveletOp instanceof AddParticipant) {
protobufOp.setAddParticipant(
((AddParticipant) waveletOp).getParticipantId().getAddress());
} else if (waveletOp instanceof RemoveParticipant) {
protobufOp.setRemoveParticipant(
((RemoveParticipant) waveletOp).getParticipantId().getAddress());
} else if (waveletOp instanceof WaveletBlipOperation) {
final WaveletBlipOperation wbOp = (WaveletBlipOperation) waveletOp;
final ProtocolWaveletOperation.MutateDocument.Builder mutation =
ProtocolWaveletOperation.MutateDocument.newBuilder();
mutation.setDocumentId(wbOp.getBlipId());
wbOp.getBlipOp().acceptVisitor(new BlipOperationVisitor() {
@Override
public void visitBlipContentOperation(BlipContentOperation blipOp) {
mutation.setDocumentOperation(serialize(blipOp.getContentOp()));
}
@Override
public void visitSubmitBlip(SubmitBlip op) {
throw new IllegalArgumentException("Unsupported blip operation: " + wbOp.getBlipOp());
}
});
protobufOp.setMutateDocument(mutation.build());
} else {
throw new IllegalArgumentException("Unsupported wavelet operation: " + waveletOp);
}
return protobufOp.build();
}
示例8: makeSegmentOperations
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
@Timed
static Map<SegmentId, SegmentOperation> makeSegmentOperations(WaveletDeltaRecord delta) {
LoadingCache<SegmentId, ImmutableList.Builder<WaveletOperation>> builders = CacheBuilder.newBuilder().build(
new CacheLoader<SegmentId, ImmutableList.Builder<WaveletOperation>>(){
@Override
public ImmutableList.Builder<WaveletOperation> load(SegmentId segmentId) {
return ImmutableList.builder();
}
});
Map<SegmentId, SegmentOperation> segmentOperations = CollectionUtils.newHashMap();
for (WaveletOperation op : delta.getTransformedDelta()) {
WaveletOperationContext newContext = makeSegmentContext(op.getContext(), delta.getResultingVersion().getVersion());
if (op instanceof AddParticipant) {
builders.getUnchecked(SegmentId.PARTICIPANTS_ID).add(
new AddParticipant(newContext, ((AddParticipant)op).getParticipantId()));
} else if (op instanceof RemoveParticipant) {
builders.getUnchecked(SegmentId.PARTICIPANTS_ID).add(
new RemoveParticipant(newContext, ((RemoveParticipant)op).getParticipantId()));
} else if (op instanceof NoOp) {
builders.getUnchecked(SegmentId.PARTICIPANTS_ID).add(new NoOp(newContext));
} else {
WaveletBlipOperation blipOp = (WaveletBlipOperation)op;
BlipContentOperation blipContentOp = (BlipContentOperation)blipOp.getBlipOp();
BlipContentOperation newBlipContentOp = new BlipContentOperation(newContext,
blipContentOp.getContentOp(), blipContentOp.getContributorMethod());
WaveletBlipOperation newBlipOp = new WaveletBlipOperation(blipOp.getBlipId(), newBlipContentOp);
builders.getUnchecked(SegmentId.ofBlipId(blipOp.getBlipId())).add(newBlipOp);
}
}
for (Entry<SegmentId, ImmutableList.Builder<WaveletOperation>> entry : builders.asMap().entrySet()) {
segmentOperations.put(entry.getKey(), new SegmentOperationImpl(entry.getValue().build()));
}
return segmentOperations;
}
示例9: applyAndReturnReverse
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
@Override
public List<? extends WaveletOperation> applyAndReturnReverse(WaveletOperation operation) throws OperationException {
nofifyBeforeUpdate();
WaveletOperationContext context = operation.getContext();
Preconditions.checkNotNull(context, "Operation has no context");
if (creator == null) {
if (rawSnapshot != null) {
creator = rawSnapshot.getCreator();
participants = new LinkedHashSet<>(rawSnapshot.getParticipants());
rawSnapshot = null;
} else {
creator = context.getCreator();
participants = new LinkedHashSet<>();
}
} else {
rawSnapshot = null;
}
if (operation instanceof AddParticipant) {
if (!participants.add(((AddParticipant)operation).getParticipantId())) {
throw new OperationException("Participant " + (((AddParticipant)operation).getParticipantId()).toString() + " already exists");
}
} else if (operation instanceof RemoveParticipant) {
if (!participants.remove(((RemoveParticipant)operation).getParticipantId())) {
throw new OperationException("No participant " + (((RemoveParticipant)operation).getParticipantId()).toString());
}
} else if (!(operation instanceof NoOp)) {
throw new RuntimeException("Invalid operation for apply to participants snapshot: " + operation);
}
return operation.reverse(context);
}
示例10: serialize
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
public static DBObject serialize(WaveletOperation waveletOp) {
final BasicDBObject mongoOp = new BasicDBObject();
if (waveletOp instanceof NoOp) {
mongoOp.append(FIELD_TYPE, WAVELET_OP_NOOP);
} else if (waveletOp instanceof AddParticipant) {
mongoOp.append(FIELD_TYPE, WAVELET_OP_ADD_PARTICIPANT);
mongoOp.append(FIELD_PARTICIPANT, serialize(((AddParticipant) waveletOp).getParticipantId()));
} else if (waveletOp instanceof RemoveParticipant) {
mongoOp.append(FIELD_TYPE, WAVELET_OP_REMOVE_PARTICIPANT);
mongoOp.append(FIELD_PARTICIPANT,
serialize(((RemoveParticipant) waveletOp).getParticipantId()));
} else if (waveletOp instanceof WaveletBlipOperation) {
final WaveletBlipOperation waveletBlipOp = (WaveletBlipOperation) waveletOp;
mongoOp.append(FIELD_TYPE, WAVELET_OP_WAVELET_BLIP_OPERATION);
mongoOp.append(FIELD_BLIPID, waveletBlipOp.getBlipId());
if (waveletBlipOp.getBlipOp() instanceof BlipContentOperation) {
mongoOp.append(FIELD_BLIPOP, serialize((BlipContentOperation) waveletBlipOp.getBlipOp()));
} else {
throw new IllegalArgumentException("Unsupported blip operation: "
+ waveletBlipOp.getBlipOp());
}
} else {
throw new IllegalArgumentException("Unsupported wavelet operation: " + waveletOp);
}
return mongoOp;
}
示例11: serializeOperation
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
private void serializeOperation(WaveletOperation operation, ProtoWaveletOperation serialized) {
if (operation instanceof AddSegment) {
serialized.setAddSegment(
serializeOptionalSegmentId(((AddSegment)operation).getSegmentId()));
} else if (operation instanceof RemoveSegment) {
serialized.setRemoveSegment(
serializeOptionalSegmentId(((RemoveSegment)operation).getSegmentId()));
} else if (operation instanceof StartModifyingSegment) {
serialized.setStartModifyingSegment(
serializeOptionalSegmentId(((StartModifyingSegment)operation).getSegmentId()));
} else if (operation instanceof EndModifyingSegment) {
serialized.setEndModifyingSegment(
serializeOptionalSegmentId(((EndModifyingSegment)operation).getSegmentId()));
} else if (operation instanceof AddParticipant) {
serialized.setAddParticipant(((AddParticipant)operation).getParticipantId().getAddress());
} else if (operation instanceof RemoveParticipant) {
serialized.setRemoveParticipant(((RemoveParticipant)operation).getParticipantId().getAddress());
} else if (operation instanceof WaveletBlipOperation) {
WaveletBlipOperation waveletOp = (WaveletBlipOperation)operation;
BlipContentOperation blipOp = (BlipContentOperation)waveletOp.getBlipOp();
switch (blipOp.getContributorMethod()) {
case ADD:
serialized.setAddDocumentContributor(true);
break;
case REMOVE:
serialized.setRemoveDocumentContributor(true);
break;
}
serialized.setDocumentOperation(operationSerializer.serialize(blipOp.getContentOp()));
} else if (operation instanceof NoOp) {
serialized.setNoOp(true);
} else {
throw new RuntimeException("Bad operation type");
}
}
示例12: deserializeOperation
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
private WaveletOperation deserializeOperation(ProtoWaveletOperation operation,
SegmentId segmentId, WaveletOperationContext context) throws InvalidParticipantAddress {
if (operation.hasAddSegment()) {
return new AddSegment(context, deserializeOptionalSegmentId(operation.getAddSegment()));
}
if (operation.hasRemoveSegment()) {
return new RemoveSegment(context, deserializeOptionalSegmentId(operation.getRemoveSegment()));
}
if (operation.hasStartModifyingSegment()) {
return new StartModifyingSegment(context, deserializeOptionalSegmentId(operation.getStartModifyingSegment()));
}
if (operation.hasEndModifyingSegment()) {
return new EndModifyingSegment(context, deserializeOptionalSegmentId(operation.getEndModifyingSegment()));
}
if (operation.hasAddParticipant()) {
return new AddParticipant(context, ParticipantId.of(operation.getAddParticipant()));
}
if (operation.hasRemoveParticipant()) {
return new RemoveParticipant(context, ParticipantId.of(operation.getRemoveParticipant()));
}
if (operation.hasDocumentOperation()) {
BlipOperation.UpdateContributorMethod method = BlipOperation.UpdateContributorMethod.NONE;
if (operation.hasAddDocumentContributor()) {
method = BlipOperation.UpdateContributorMethod.ADD;
} else if (operation.hasRemoveDocumentContributor()) {
method = BlipOperation.UpdateContributorMethod.REMOVE;
}
DocOp docOp = WaveletOperationSerializer.deserialize(operation.getDocumentOperation());
BlipContentOperation blipOp = new BlipContentOperation(context, docOp, method);
return new WaveletBlipOperation(segmentId.getBlipId(), blipOp);
}
if (operation.hasNoOp()) {
return new NoOp(context);
}
Preconditions.nullPointer("Invalid operation " + operation);
return null; // unreachable
}
示例13: isNoop
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
/**
* Returns true iff the wavelet operation is considered a no-op as far as undo
* is concerned.
*
* @param op
*/
static boolean isNoop(WaveletOperation op) {
if (op instanceof VersionUpdateOp || op instanceof NoOp) {
return true;
} else if (op instanceof AddParticipant || op instanceof RemoveParticipant
|| op instanceof WaveletBlipOperation) {
return false;
} else {
// This happens when the op parameter is a non-core subclass of
// WaveletOperation, not supported by wave.
throw new RuntimeException("Unhandled op:" + op.getClass());
}
}
示例14: testNonContiguousDeltas
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
public void testNonContiguousDeltas() throws Exception {
TransformedWaveletDelta deltaAdd = new TransformedWaveletDelta(ALEX, V1, 0L,
Arrays.asList(new NoOp(new WaveletOperationContext(ALEX, 0L, 1, V1))));
TransformedWaveletDelta deltaRemove = new TransformedWaveletDelta(ALEX, V2, 0L,
Arrays.asList(new NoOp(new WaveletOperationContext(ALEX, 0L, 2, V2))));
DeltaSequence deltas = DeltaSequence.of(deltaAdd, deltaRemove);
try {
wavelet.appendDeltas(waveletData, deltas);
fail("Expected exception because deltas aren't contiguous");
} catch (IllegalArgumentException e) {
// Expected
}
}
示例15: makeNoOpDelta
import org.waveprotocol.wave.model.operation.wave.NoOp; //导入依赖的package包/类
/**
* Builds a no-op client delta.
*/
public WaveletDelta makeNoOpDelta(HashedVersion targetVersion, long timestamp, int numOps) {
List<WaveletOperation> ops = CollectionUtils.newArrayList();
WaveletOperationContext context =
new WaveletOperationContext(author, Constants.NO_TIMESTAMP, 1);
for (int i = 0; i < numOps; ++i) {
ops.add(new NoOp(context));
}
return new WaveletDelta(author, targetVersion, ops);
}