本文整理汇总了Java中org.waveprotocol.wave.model.util.Preconditions.illegalArgument方法的典型用法代码示例。如果您正苦于以下问题:Java Preconditions.illegalArgument方法的具体用法?Java Preconditions.illegalArgument怎么用?Java Preconditions.illegalArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.waveprotocol.wave.model.util.Preconditions
的用法示例。
在下文中一共展示了Preconditions.illegalArgument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: insertBlip
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
@Override
public WaveletBasedConversationBlip insertBlip(ConversationBlip neighbor, boolean beforeNeighbor) {
checkIsUsable();
if (!blips.containsKey(neighbor.getId())) {
Preconditions.illegalArgument(
"Can't insert a blip: the blip " + neighbor + " is not from this thread");
}
WaveletBasedConversationBlip neighborBlip = (WaveletBasedConversationBlip) neighbor;
int index = manifestThread.indexOf(neighborBlip.getManifestBlip());
if (!beforeNeighbor) {
index++;
}
Blip blip = helper.createBlip(null);
String blipId = blip.getId();
manifestThread.insertBlip(index, blipId);
return blips.get(blipId);
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:18,代码来源:WaveletBasedConversationThread.java示例2: ofLegacy
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
/**
* Creates a wavelet id without doing validity checking, except for a
* deprecated serialization scheme.
*
* @param domain must not be null. This is assumed to be of a valid canonical
* domain format.
* @param id must not be null. This is assumed to be escaped with
* SimplePrefixEscaper.DEFAULT_ESCAPER.
* @throws IllegalArgumentException if domain or id is invalid.
*/
public static WaveletId ofLegacy(String domain, String id) {
Preconditions.checkNotNull(domain, "Null domain");
Preconditions.checkNotNull(id, "Null id");
Preconditions.checkArgument(!domain.isEmpty(), "Empty domain");
Preconditions.checkArgument(!id.isEmpty(), "Empty id");
if (SimplePrefixEscaper.DEFAULT_ESCAPER.hasEscapeCharacters(domain)) {
Preconditions.illegalArgument(
"Domain cannot contain characters that requires escaping: " + domain);
}
if (!SimplePrefixEscaper.DEFAULT_ESCAPER.isEscapedProperly(IdConstants.TOKEN_SEPARATOR, id)) {
Preconditions.illegalArgument("Id is not properly escaped: " + id);
}
return new WaveletId(domain, id);
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:28,代码来源:WaveletId.java示例3: createStacklet
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
/**
* Adds a new operation-channel stacklet to this multiplexer and notifies the
* listener of the new channel's creation.
*
* @param waveletId id of the concurrency domain for the new channel
* @param snapshot wavelet initial state snapshot
* @param accessibility accessibility of the stacklet; if not
* {@link Accessibility#READ_WRITE} then
* the stacklet will fail on send
*/
private Stacklet createStacklet(final WaveletId waveletId, ObservableWaveletFragmentData snapshot,
Accessibility accessibility) {
if (channels.containsKey(waveletId)) {
Preconditions.illegalArgument("Cannot create duplicate channel for wavelet: " + waveId + "/"
+ waveletId);
}
WaveletChannel waveletChannel = createWaveletChannel(waveletId);
WaveletDeltaChannel deltaChannel = deltaChannelFactory.create(waveletChannel);
InternalOperationChannel opChannel = opChannelFactory.create(deltaChannel, waveletId,
snapshot.getHashedVersion(), accessibility);
Stacklet stacklet = new Stacklet(deltaChannel, opChannel);
stacklet.reset();
channels.put(waveletId, stacklet);
if (channelsPresenceListener != null) {
channelsPresenceListener.onOperationChannelCreated(stacklet.getOperationChannel(), snapshot,
accessibility);
}
return stacklet;
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:32,代码来源:OperationChannelMultiplexerImpl.java示例4: ImmutableStateMap
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
public ImmutableStateMap(String ... pairs) {
Preconditions.checkArgument(pairs.length % 2 == 0, "Pairs must come in groups of two");
Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i < pairs.length; i += 2) {
Preconditions.checkNotNull(pairs[i], "Null key");
Preconditions.checkNotNull(pairs[i + 1], "Null value");
if (map.containsKey(pairs[i])) {
Preconditions.illegalArgument("Duplicate key: " + pairs[i]);
}
map.put(pairs[i], pairs[i + 1]);
}
this.attributes = attributeListFromMap(map);
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:17,代码来源:ImmutableStateMap.java示例5: getStartVersion
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
/**
* Gets start version of segment, from which changes are displayed.
*
* @param waveletId the Id of wavelet.
* @param segmentId the Id of segment.
* @param segmentCreationVersion the creation segment version.
* @return last look version of segment or {@link #NO_VERSION}.
*/
public long getStartVersion(WaveletId waveletId, SegmentId segmentId, long segmentCreationVersion) {
long version = PrimitiveSupplement.NO_VERSION;
if (supplement != null) {
if (segmentId.isIndex()) {
version = getLookWaveletVersion(waveletId);
} else if (segmentId.isParticipants()) {
version = getLookParticipantsVersion(waveletId, segmentCreationVersion);
} else if (segmentId.isBlip()) {
if (IdConstants.TAGS_DOCUMENT_ID.equals(segmentId.getBlipId())) {
version = getLookTagsVersion(waveletId, segmentCreationVersion);
} else {
version = getLookBlipVersion(waveletId, segmentId.getBlipId(), segmentCreationVersion);
}
} else {
Preconditions.illegalArgument("Invalid segment " + segmentId.toString());
}
}
return version != PrimitiveSupplement.NO_VERSION && version != 0 && version >= segmentCreationVersion ? version : NO_VERSION;
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:28,代码来源:StartVersionHelper.java示例6: deserializeMarker
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
/**
* Deserializes marker at offset of required type mask.
*/
private Marker deserializeMarker(int offset, int markerTypeMask) {
Preconditions.checkArgument(offset <= markersBufferLength, "Invalid offset");
if (offset == markersBufferLength) {
return null;
}
int type = markersBuffer[offset] & 0xFF;
if ((type & markerTypeMask) == 0) {
return null;
}
int len = markersBuffer[offset+1] & 0xFF;
ByteArrayInputStream in = new ByteArrayInputStream(markersBuffer, offset+2, len);
Marker marker = null;
if (type == MARKER_TYPE_TOP) {
marker = TopMarkerImpl.deserialize(in);
} else if (type == MARKER_TYPE_FAR_BACKWARD) {
marker = FarBackwardMarkerImpl.deserialize(in);
} else if (type == MARKER_TYPE_FAR_FORWARD) {
marker = FarForwardMarkerImpl.deserialize(in);
} else if (type == MARKER_TYPE_SNAPSHOT) {
marker = SnapshotMarkerImpl.deserialize(in);
} else {
Preconditions.illegalArgument("Invalid marker type " + type);
}
int nextMarkerOffset = offset+len+3;
marker.setNextMarkerOffset(nextMarkerOffset);
if (offset > 0) {
int prevMarkerLen = markersBuffer[offset-1] & 0xFF;
marker.setPreviousMarkerOffset(offset-prevMarkerLen-3);
}
return marker;
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:35,代码来源:FragmentIndex.java示例7: getDocument
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
@Override
public ObservableDocument getDocument(String docId) {
Blip blip = getBlip(docId);
if (blip == null) {
blip = createBlip(docId);
}
Document doc = blip.getDocument();
if (!(doc instanceof ObservableDocument)) {
Preconditions.illegalArgument("Document \"" + docId + "\" is not observable");
}
return (ObservableDocument) doc;
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:13,代码来源:OpBasedWavelet.java示例8: getConversation
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
/**
* Gets the conversation backed by a wavelet; null if the wavelet is not in
* view or does not have conversation structure.
*/
public WaveletBasedConversation getConversation(WaveletId id) {
if (!IdUtil.isConversationalId(id)) {
Preconditions.illegalArgument("Wavelet id " + id + " is not conversational");
}
ObservableWavelet wavelet = waveView.getWavelet(id);
if (wavelet != null) {
return conversations.get(wavelet);
}
return null;
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:15,代码来源:WaveBasedConversationView.java示例9: getDataDocument
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
@Override
public ObservableDocument getDataDocument(String name) {
if (IdUtil.isBlipId(name)) {
Preconditions.illegalArgument("Cannot fetch blip document " + name + " as a data document");
} else if (IdConstants.MANIFEST_DOCUMENT_ID.equals(name)) {
Preconditions.illegalArgument("Cannot fetch conversation manifest as a data document");
}
return wavelet.getDocument(name);
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:10,代码来源:WaveletBasedConversation.java示例10: createOperationChannel
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
@Override
public void createOperationChannel(WaveletId waveletId, ParticipantId creator) {
if (channels.containsKey(waveletId)) {
Preconditions.illegalArgument("Operation channel already exists for: " + waveletId);
}
// Create the new channel, and fake an initial snapshot.
// TODO(anorth): inject a clock for providing timestamps.
HashedVersion v0 = hashFactory.createVersionZero(WaveletName.of(waveId, waveletId));
ObservableWaveletFragmentData emptySnapshot =
dataFactory.create(
new EmptyWaveletFragmentSnapshot(waveId, waveletId, creator, v0, System.currentTimeMillis()));
createStacklet(waveletId, emptySnapshot, Accessibility.READ_WRITE);
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:16,代码来源:OperationChannelMultiplexerImpl.java示例11: updateWith
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
private T updateWith(U attributeUpdate, boolean checkCompatibility) {
List<Attribute> newImmutableStateMap = new ArrayList<Attribute>();
Iterator<Attribute> iterator = attributes.iterator();
Attribute nextAttribute = iterator.hasNext() ? iterator.next() : null;
// TODO: Have a slow path when the cast would fail.
List<AttributeUpdate> updates = ((ImmutableUpdateMap<?,?>) attributeUpdate).updates;
for (AttributeUpdate update : updates) {
while (nextAttribute != null) {
int comparison = update.name.compareTo(nextAttribute.name);
if (comparison > 0) {
newImmutableStateMap.add(nextAttribute);
nextAttribute = iterator.hasNext() ? iterator.next() : null;
} else if (comparison < 0) {
if (checkCompatibility && update.oldValue != null) {
Preconditions.illegalArgument(
"Mismatched old value: attempt to update unset attribute with " + update);
}
break;
} else if (comparison == 0) {
if (checkCompatibility && !nextAttribute.value.equals(update.oldValue)) {
Preconditions.illegalArgument(
"Mismatched old value: attempt to update " + nextAttribute + " with " + update);
}
nextAttribute = iterator.hasNext() ? iterator.next() : null;
break;
}
}
if (update.newValue != null) {
newImmutableStateMap.add(new Attribute(update.name, update.newValue));
}
}
if (nextAttribute != null) {
newImmutableStateMap.add(nextAttribute);
while (iterator.hasNext()) {
newImmutableStateMap.add(iterator.next());
}
}
return createFromList(newImmutableStateMap);
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:40,代码来源:ImmutableStateMap.java示例12: composeWith
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
public T composeWith(U mutation) {
List<AttributeUpdate> newAttributes = new ArrayList<AttributeUpdate>();
Iterator<AttributeUpdate> iterator = updates.iterator();
AttributeUpdate nextAttribute = iterator.hasNext() ? iterator.next() : null;
// TODO: Have a slow path when the cast would fail.
List<AttributeUpdate> mutationAttributes = ((ImmutableUpdateMap<?,?>) mutation).updates;
loop: for (AttributeUpdate attribute : mutationAttributes) {
while (nextAttribute != null) {
int comparison = comparator.compare(attribute, nextAttribute);
if (comparison < 0) {
break;
} else if (comparison > 0) {
newAttributes.add(nextAttribute);
nextAttribute = iterator.hasNext() ? iterator.next() : null;
} else {
if (!areEqual(nextAttribute.newValue, attribute.oldValue)) {
Preconditions.illegalArgument(
"Mismatched old value: attempt to update " + nextAttribute + " with " + attribute);
}
newAttributes.add(new AttributeUpdate(attribute.name, nextAttribute.oldValue,
attribute.newValue));
nextAttribute = iterator.hasNext() ? iterator.next() : null;
continue loop;
}
}
newAttributes.add(attribute);
}
if (nextAttribute != null) {
newAttributes.add(nextAttribute);
while (iterator.hasNext()) {
newAttributes.add(iterator.next());
}
}
return createFromList(newAttributes);
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:36,代码来源:ImmutableUpdateMap.java示例13: check
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
private void check(int i, DocOpComponentType expectedType) {
DocOpComponentType actualType = components[i].getType();
if (actualType != expectedType) {
Preconditions.illegalArgument(
"Component " + i + " is not of type ' " + expectedType + "', it is '" + actualType + "'");
}
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:8,代码来源:BufferedDocOpImpl.java示例14: Range
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
/**
* Construct a range
*
* @param start
* @param end
*/
public Range(int start, int end) {
if (start < 0 || start > end) {
Preconditions.illegalArgument("Bad range: (" + start + ", " + end + ")");
}
this.start = start;
this.end = end;
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:14,代码来源:Range.java示例15: deleteLine
import org.waveprotocol.wave.model.util.Preconditions; //导入方法依赖的package包/类
/**
* Deletes a line inside of a line container. Takes care to not invalidate
* the schema by leaving an empty line container. If the line to be deleted
* is the last one, then it will be emptied and left alone instead.
*
* @param doc
* @param line the element marking the start of the line to remove.
*/
public static <N, E extends N, T extends N> void deleteLine(MutableDocument<N, E, T> doc,
E line) {
checkNotParagraphDocument(doc);
if (!isLineElement(doc, line)) {
Preconditions.illegalArgument("Not a line element: " + line);
}
E lc = doc.getParentElement(line);
if (!isLineContainer(doc, lc)) {
Preconditions.illegalArgument("Not a line container: " + lc);
}
boolean isFirstLine = doc.getFirstChild(lc) == line;
Point<N> deleteEndPoint =
roundLocation(doc, Rounding.LINE, Point.after(doc, line), RoundDirection.RIGHT);
// If this is not the first line or there is another line, then we can
// delete this one. Otherwise, empty it and leave it.
Point<N> deleteStartPoint;
if (!isFirstLine || isLineElement(doc, deleteEndPoint.getNodeAfter())) {
deleteStartPoint = Point.before(doc, line);
} else {
doc.emptyElement(line);
deleteStartPoint = Point.after(doc, line);
}
doc.deleteRange(deleteStartPoint, deleteEndPoint);
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:37,代码来源:LineContainers.java本文标签属性:
示例:示例英语
代码:代码生成器
java:java自行车
Preconditions:precondition什么意思
illegalArgument:illegalargumentexcepiton异常解决办法