List of usage examples for com.google.common.base Preconditions checkState
public static void checkState(boolean expression)
From source file:org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationPayload.java
@Override public Map<GeneratedMessage.GeneratedExtension, PersistentMessages.CompositeModification> encode() { Preconditions.checkState(modification != null); Map<GeneratedMessage.GeneratedExtension, PersistentMessages.CompositeModification> map = new HashMap<>(); map.put(org.opendaylight.controller.protobuff.messages.shard.CompositeModificationPayload.modification, this.modification); return map;// www . jav a 2s.co m }
From source file:org.geogit.storage.memory.Graph.java
/** * Creates a new node in the graph./* w w w .j av a 2 s. co m*/ * * @param id The id of the new node. */ public Node newNode(ObjectId id) { Preconditions.checkNotNull(id); Preconditions.checkState(nodes.get(id) == null); Node n = new Node(id); nodes.put(id, n); return n; }
From source file:fathom.rest.controller.extractors.AuthExtractor.java
@Override public void setObjectType(Class<?> objectType) { Preconditions.checkState(Account.class.isAssignableFrom(objectType)); }
From source file:org.ros.tutorials.poark.Basic.java
@Override public void main(Node node) throws Exception { Preconditions.checkState(this.node == null); this.node = node; try {/*from w w w . java2s. com*/ final Log log = node.getLog(); // Attach the client to the node and add some pin listeners. poarkClient = new PoarkClient(Poark.BoardLayout.MegaLayout, node); poarkClient.addPinChangeListener(kButton1, new PinChangeListener() { @Override public void onPinStateChange(byte pin, int new_value) { log.info("Pushed the button : \"" + pin + " - " + new_value + "\""); } }); poarkClient.setPinMode(kLedPin, Poark.OUT, Poark.HIGH); Thread.sleep(1000); // Setup the Poark I/O. poarkClient.setPinsMode(new byte[] { kLedPin, kButton1 }, new byte[] { Poark.OUT, Poark.IN }, new byte[] { Poark.LOW, Poark.HIGH }); // Start blinking the light. byte light = Poark.LOW; while (true) { light = (byte) (Poark.HIGH - light); poarkClient.setPinState(kLedPin, light); Thread.sleep(1000); } } catch (Exception e) { if (node != null) { node.getLog().fatal(e); } else { e.printStackTrace(); } } }
From source file:com.palantir.atlasdb.keyvalue.partition.util.CycleMap.java
public K previousKey(K key) { Preconditions.checkState(size() > 0); K previous = lowerKey(key);/* ww w . ja va2 s .co m*/ if (previous == null) { previous = lastKey(); } return previous; }
From source file:org.apache.tez.dag.app.launcher.ContainerOp.java
public ContainerLaunchRequest getLaunchRequest() { Preconditions.checkState(opType == OPType.LAUNCH_REQUEST); return (ContainerLaunchRequest) command; }
From source file:appeng.bootstrap.components.BuiltInModelComponent.java
public void addModel(String path, IModel model) { Preconditions.checkState(!hasInitialized); builtInModels.put(path, model); }
From source file:com.google.devtools.build.skyframe.TrackingInvalidationReceiver.java
@Override public void invalidated(SkyValue value, InvalidationState state) { switch (state) { case DELETED: dirty.remove(value);/*w w w. ja va 2 s . co m*/ deleted.add(value); break; case DIRTY: dirty.add(value); Preconditions.checkState(!deleted.contains(value)); break; default: throw new IllegalStateException(); } }
From source file:com.cloudera.impala.analysis.AlterTableAddPartitionStmt.java
public AlterTableAddPartitionStmt(TableName tableName, PartitionSpec partitionSpec, HdfsUri location, boolean ifNotExists, HdfsCachingOp cacheOp) { super(tableName); Preconditions.checkState(partitionSpec != null); location_ = location;/*from w ww. j a v a2 s . c o m*/ ifNotExists_ = ifNotExists; partitionSpec_ = partitionSpec; partitionSpec_.setTableName(tableName); cacheOp_ = cacheOp; }
From source file:com.mapr.workGroup.GroupThread.java
protected void setState(Logger log, ThreadState state) { Preconditions.checkState(ThreadState.check(currentState, state)); log.info("Transitioning from {} to {}", state); currentState = state;/*from www .j av a 2 s . c o m*/ }