List of usage examples for com.google.common.base Preconditions checkState
public static void checkState(boolean expression, @Nullable Object errorMessage)
From source file:com.gradleware.tooling.toolingmodel.repository.internal.DefaultOmniGradleBuild.java
public static DefaultOmniGradleBuild from(GradleProject gradleRootProject, boolean enforceAllTasksPublic) { Preconditions.checkState(gradleRootProject.getParent() == null, "Provided Gradle project is not the root project."); return new DefaultOmniGradleBuild(DefaultOmniGradleProject.from(gradleRootProject, enforceAllTasksPublic)); }
From source file:codecrafter47.bungeetablistplus.api.bukkit.BungeeTabListPlusBukkitAPI.java
/** * Registers a custom variable/* w w w. jav a 2s. c o m*/ * <p> * You cannot use this to replace existing variables. If registering a variable which already * exists there may be an exception thrown but there is no guarantee that an exception * is thrown in that case. * * @param plugin your plugin * @param variable your variable */ public static void registerVariable(Plugin plugin, Variable variable) { Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); instance.registerVariable0(plugin, variable); }
From source file:edu.umn.msi.tropix.persistence.service.impl.Utils.java
static void initObject(final TropixObject object) { //Preconditions.checkState(object.getId() == null, "Object with nonnull id sent to initAndSaveObject id is " + object.getId()); Preconditions.checkState(object.getCreationTime() == null, "Object with creation time already sent to initAndSaveObject id is " + object.getId()); setCreationTime(object);// ww w. j a va2 s. c om object.setPermissionParents(new HashSet<TropixObject>()); object.setPermissionChildren(new HashSet<TropixObject>()); object.setParentVirtualFolders(new HashSet<VirtualFolder>()); }
From source file:org.apache.james.jmap.model.ProtocolRequest.java
public static ProtocolRequest deserialize(JsonNode[] json) { Preconditions.checkState(json.length == 3, "should have three elements"); Preconditions.checkState(json[0].isTextual(), "first element should be a String"); Preconditions.checkState(json[1].isObject(), "second element should be a Json"); Preconditions.checkState(json[2].isTextual(), "third element should be a String"); return new ProtocolRequest(Method.Request.name(json[0].textValue()), (ObjectNode) json[1], ClientId.of(json[2].textValue())); }
From source file:me.lucko.luckperms.common.api.internal.Utils.java
public static void checkUser(User user) { Preconditions.checkState(user instanceof UserLink, "User instance cannot be handled by this implementation."); }
From source file:com.github.jcustenborder.kafka.connect.utils.config.TaskConfigs.java
/** * Method is used to generate a list of taskConfigs based on the supplied settings. * * @param settings/*from w w w. j a v a2 s . c o m*/ * @param taskCount * @return */ public static List<Map<String, String>> multiple(Map<String, String> settings, final int taskCount) { Preconditions.checkNotNull(settings, "settings cannot be null."); Preconditions.checkState(taskCount > 0, "taskCount must be greater than 0."); final List<Map<String, String>> result = new ArrayList<>(taskCount); for (int i = 0; i < taskCount; i++) { result.add(settings); } return ImmutableList.copyOf(result); }
From source file:org.opendaylight.netconf.sal.streams.websockets.WebSocketServer.java
/** * Create singleton instance of {@link WebSocketServer} * * @param port TCP port used for this server * @return instance of {@link WebSocketServer} *//* www.jav a 2 s. co m*/ public static WebSocketServer createInstance(final int port) { Preconditions.checkState(instance == null, "createInstance() has already been called"); Preconditions.checkArgument(port >= 1024, "Privileged port (below 1024) is not allowed"); instance = new WebSocketServer(port); return instance; }
From source file:com.tellapart.taba.TabaApiFactory.java
public static synchronized void initialize(TabaClientEngine clientEngine) { Preconditions.checkState(engine == null, "Already initialized."); engine = clientEngine;/*w w w . j a va2s . c o m*/ api = new TabaApi(engine); }
From source file:com.dmdirc.addons.ui_swing.SwingPreconditions.java
/** * Checks that the method is called on the Swing EDT. * * @throws IllegalStateException if the method is called from another thread. *//* w w w.j a va 2s . c o m*/ public static void checkOnEDT() { Preconditions.checkState(SwingUtilities.isEventDispatchThread(), "Must be called on the event despatch thread"); }
From source file:pocman.game.Tiles.java
public static Tile fromCharacter(final Character character) { Preconditions.checkArgument(character != null); final Tile tile = TILE_BY_CHARACTER_MAP.get(character); Preconditions.checkState(tile != null, "Unknown tile from character: " + character); return tile;//from w w w . j av a2 s . co m }