Java Code Examples for org.apache.commons.lang.Validate#notNull()
The following examples show how to use
org.apache.commons.lang.Validate#notNull() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatementSerializer.java From rya with Apache License 2.0 | 5 votes |
private static Literal parseLiteral(final String fullLiteralString) { Validate.notNull(fullLiteralString); Validate.isTrue(fullLiteralString.length() > 1); if (fullLiteralString.endsWith("\"")) { final String fullLiteralWithoutQuotes = fullLiteralString.substring(1, fullLiteralString.length() - 1); return VF.createLiteral(fullLiteralWithoutQuotes); } else { // find the closing quote final int labelEnd = fullLiteralString.lastIndexOf("\""); final String label = fullLiteralString.substring(1, labelEnd); final String data = fullLiteralString.substring(labelEnd + 1); if (data.startsWith(LiteralLanguageUtils.LANGUAGE_DELIMITER)) { // the data is "language" final String lang = data.substring(1); return VF.createLiteral(label, lang); } else if (data.startsWith("^^<")) { // the data is a "datatype" final String datatype = data.substring(3, data.length() - 1); final IRI datatypeUri = VF.createIRI(datatype); return VF.createLiteral(label, datatypeUri); } } return null; }
Example 2
Source File: UnLocode.java From dddsample-core with MIT License | 5 votes |
/** * Constructor. * * @param countryAndLocation Location string. */ public UnLocode(final String countryAndLocation) { Validate.notNull(countryAndLocation, "Country and location may not be null"); Validate.isTrue(VALID_PATTERN.matcher(countryAndLocation).matches(), countryAndLocation + " is not a valid UN/LOCODE (does not match pattern)"); this.unlocode = countryAndLocation.toUpperCase(); }
Example 3
Source File: TemplateEntry.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public void removeCalendarProperties(final Integer calId) { Validate.notNull(calId); final TemplateCalendarProperties props = getCalendarProperties(calId); if (props != null) { this.calendarProperties.remove(props); } this.visibleCalendarIds = null; }
Example 4
Source File: CraftProfileBanList.java From Thermos with GNU General Public License v3.0 | 5 votes |
@Override public boolean isBanned(String target) { Validate.notNull(target, "Target cannot be null"); GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(target); if (profile == null) { return false; } return list.func_152702_a(profile); }
Example 5
Source File: KeyStoreInfo.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public KeyStoreInfo(String pathKeystore, String keystoreType, char[] pwdKeystore, String alias, char[] privateKeyPwd) throws TechnicalConnectorException { Validate.notEmpty(alias); Validate.notNull(privateKeyPwd); if (StringUtils.isNotEmpty(pathKeystore)) { Validate.notEmpty(keystoreType); Validate.notNull(pwdKeystore); } this.keystorePath = this.getKeystoreLoc(pathKeystore); this.keystoreType = keystoreType; this.keystorePassword = ArrayUtils.clone(pwdKeystore); this.alias = alias; this.privateKeyPassword = ArrayUtils.clone(privateKeyPwd); }
Example 6
Source File: OrderProcessingRoute.java From camel-cookbook-examples with Apache License 2.0 | 5 votes |
@PostConstruct public void checkMandatoryProperties() { Validate.notEmpty(id, "id is empty"); Validate.notEmpty(inputDirectory, "inputDirectory is empty"); Validate.notEmpty(outputDirectory, "outputDirectory is empty"); Validate.notNull(orderFileNameProcessor, "orderFileNameProcessor is null"); }
Example 7
Source File: BlockMenuPreset.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
public void newInstance(BlockMenu menu, Location l) { Validate.notNull(l, "Cannot create a new BlockMenu without a Location"); Slimefun.runSync(() -> { locked = true; try { newInstance(menu, l.getBlock()); } catch (Exception | LinkageError x) { getSlimefunItem().error("An Error occurred while trying to create a BlockMenu", x); } }); }
Example 8
Source File: Waypoint.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
public Waypoint(PlayerProfile profile, String id, Location l, String name) { Validate.notNull(profile, "Profile must never be null!"); Validate.notNull(id, "id must never be null!"); Validate.notNull(l, "Location must never be null!"); Validate.notNull(name, "Name must never be null!"); this.profile = profile; this.id = id; this.location = l; this.name = name; }
Example 9
Source File: GetWorkflowInstMetCliAction.java From oodt with Apache License 2.0 | 5 votes |
@Override public void execute(ActionMessagePrinter printer) throws CmdLineActionException { Validate.notNull(instanceId); try (WorkflowManagerClient client = getClient()) { Metadata met = client.getWorkflowInstanceMetadata(instanceId); printer.println("[id=" + instanceId + ", met=" + met.getMap() + "]"); } catch (Exception e) { throw new CmdLineActionException( "Failed to get metadata for workflow instance '" + instanceId + "' : " + e.getMessage(), e); } }
Example 10
Source File: ContractRequestBuilder.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public ContractRequestBuilder.OrganizationChoiceStep2 withId(String id, IdentifierType type) { Validate.notEmpty(id); Validate.notNull(type); this.organizationId = id; this.organizationIdentifier = type; return this; }
Example 11
Source File: RuntimesHost.java From reef with Apache License 2.0 | 5 votes |
/** * Retrieves requested runtime, if requested name is empty a default runtime will be used. * @param requestedRuntimeName the requested runtime name * @return The runtime */ private Runtime getRuntime(final String requestedRuntimeName) { final String runtimeName = StringUtils.isBlank(requestedRuntimeName) ? this.defaultRuntimeName : requestedRuntimeName; final Runtime runtime = this.runtimes.get(runtimeName); Validate.notNull(runtime, "Couldn't find runtime for name " + runtimeName); return runtime; }
Example 12
Source File: KinesisRecordProcessor.java From samza with Apache License 2.0 | 5 votes |
/** * Invoked by the Amazon Kinesis Client Library before data records are delivered to the RecordProcessor instance * (via processRecords). * * @param initializationInput Provides information related to initialization */ @Override public void initialize(InitializationInput initializationInput) { Validate.notNull(listener, "There is no listener set for the processor."); initSeqNumber = initializationInput.getExtendedSequenceNumber(); shardId = initializationInput.getShardId(); LOG.info("Initialization done for {} with sequence {}", this, initializationInput.getExtendedSequenceNumber().getSequenceNumber()); }
Example 13
Source File: TaskDao.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
@Override public boolean hasDeleteAccess(final PFUserDO user, final TaskDO obj, final TaskDO dbObj, final boolean throwException) { Validate.notNull(obj); if (hasUpdateAccess(user, obj, dbObj, throwException) == true) { return true; } if (accessChecker.isUserMemberOfGroup(user, ProjectForgeGroup.ADMIN_GROUP, ProjectForgeGroup.FINANCE_GROUP) == true) { return true; } return accessChecker.hasPermission(user, obj.getParentTaskId(), AccessType.TASKS, OperationType.DELETE, throwException); }
Example 14
Source File: RemoveNodeFromQueueCliAction.java From oodt with Apache License 2.0 | 5 votes |
@Override public void execute(ActionMessagePrinter printer) throws CmdLineActionException { try { Validate.notNull(nodeId, "Must specify nodeId"); Validate.notNull(queueName, "Must specify queueName"); getClient().removeNodeFromQueue(nodeId, queueName); printer.println("Successfully removed node from queue!"); } catch (Exception e) { throw new CmdLineActionException("Failed to remove node '" + nodeId + "' from queue '" + queueName + "' : " + e.getMessage(), e); } }
Example 15
Source File: TimesheetDao.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * Analyses all time sheets of the user and detects any collision (overlap) of the user's time sheets. The result will be cached and the * duration of a new analysis is only a few milliseconds! * @param user * @return */ public Set<Integer> getTimesheetsWithTimeoverlap(final Integer userId) { Validate.notNull(userId); final PFUserDO user = userGroupCache.getUser(userId); Validate.notNull(user); synchronized (timesheetsWithOverlapByUser) { if (timesheetsWithOverlapByUser.get(userId) != null) { return timesheetsWithOverlapByUser.get((userId)); } // log.info("Getting time sheet overlaps for user: " + user.getUsername()); final Set<Integer> result = new HashSet<Integer>(); final QueryFilter queryFilter = new QueryFilter(); queryFilter.add(Restrictions.eq("user", user)); queryFilter.addOrder(Order.asc("startTime")); final List<TimesheetDO> list = getList(queryFilter); long endTime = 0; TimesheetDO lastEntry = null; for (final TimesheetDO entry : list) { if (entry.getStartTime().getTime() < endTime) { // Time collision! result.add(entry.getId()); if (lastEntry != null) { // Only for first iteration result.add(lastEntry.getId()); // Also collision for last entry. } } endTime = entry.getStopTime().getTime(); lastEntry = entry; } timesheetsWithOverlapByUser.put(user.getId(), result); if (CollectionUtils.isNotEmpty(result) == true) { log.info("Time sheet overlaps for user '" + user.getUsername() + "': " + result); } return result; } }
Example 16
Source File: Representable.java From keycloak with Apache License 2.0 | 5 votes |
public default String getIdFromRepresentation(REP representation) { Validate.notNull(representation); try { Class<REP> c = (Class<REP>) representation.getClass(); Method getId = c.getMethod("getId"); Validate.notNull(getId); return (String) getId.invoke(representation); } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new RuntimeException(ex); } }
Example 17
Source File: JsonUtils.java From brooklin with BSD 2-Clause "Simplified" License | 5 votes |
/** * Deserialize a JSON string into an object based on a type reference. * This method allows the caller to specify precisely the desired output * type for the target object. * @param json JSON string * @param typeRef type reference of the target object * @param <T> type of the target object * @return deserialized Java object */ public static <T> T fromJson(String json, TypeReference<T> typeRef) { Validate.notNull(json, "null JSON string"); Validate.notNull(typeRef, "null type reference"); T object = null; try { object = MAPPER.readValue(json, typeRef); } catch (IOException e) { String errorMessage = "Failed to parse json: " + json; ErrorLogger.logAndThrowDatastreamRuntimeException(LOG, errorMessage, e); } return object; }
Example 18
Source File: RangerSearchUtil.java From ranger with Apache License 2.0 | 4 votes |
public SearchFilter getSearchFilter(@Nonnull HttpServletRequest request, List<SortField> sortFields) { Validate.notNull(request, "request"); SearchFilter ret = new SearchFilter(); if (MapUtils.isEmpty(request.getParameterMap())) { ret.setParams(new HashMap<String, String>()); } ret.setParam(SearchFilter.SERVICE_TYPE, request.getParameter(SearchFilter.SERVICE_TYPE)); ret.setParam(SearchFilter.SERVICE_TYPE_DISPLAY_NAME, request.getParameter(SearchFilter.SERVICE_TYPE_DISPLAY_NAME)); ret.setParam(SearchFilter.SERVICE_TYPE_ID, request.getParameter(SearchFilter.SERVICE_TYPE_ID)); ret.setParam(SearchFilter.SERVICE_NAME, request.getParameter(SearchFilter.SERVICE_NAME)); ret.setParam(SearchFilter.SERVICE_DISPLAY_NAME, request.getParameter(SearchFilter.SERVICE_DISPLAY_NAME)); ret.setParam(SearchFilter.SERVICE_NAME_PARTIAL, request.getParameter(SearchFilter.SERVICE_NAME_PARTIAL)); ret.setParam(SearchFilter.SERVICE_DISPLAY_NAME_PARTIAL, request.getParameter(SearchFilter.SERVICE_DISPLAY_NAME_PARTIAL)); ret.setParam(SearchFilter.SERVICE_ID, request.getParameter(SearchFilter.SERVICE_ID)); ret.setParam(SearchFilter.POLICY_NAME, request.getParameter(SearchFilter.POLICY_NAME)); ret.setParam(SearchFilter.POLICY_NAME_PARTIAL, request.getParameter(SearchFilter.POLICY_NAME_PARTIAL)); ret.setParam(SearchFilter.POLICY_ID, request.getParameter(SearchFilter.POLICY_ID)); ret.setParam(SearchFilter.IS_ENABLED, request.getParameter(SearchFilter.IS_ENABLED)); ret.setParam(SearchFilter.IS_RECURSIVE, request.getParameter(SearchFilter.IS_RECURSIVE)); ret.setParam(SearchFilter.USER, request.getParameter(SearchFilter.USER)); ret.setParam(SearchFilter.GROUP, request.getParameter(SearchFilter.GROUP)); ret.setParam(SearchFilter.POL_RESOURCE, request.getParameter(SearchFilter.POL_RESOURCE)); ret.setParam(SearchFilter.RESOURCE_SIGNATURE, request.getParameter(SearchFilter.RESOURCE_SIGNATURE)); ret.setParam(SearchFilter.POLICY_TYPE, request.getParameter(SearchFilter.POLICY_TYPE)); ret.setParam(SearchFilter.POLICY_LABEL, request.getParameter(SearchFilter.POLICY_LABEL)); ret.setParam(SearchFilter.POLICY_LABELS_PARTIAL, request.getParameter(SearchFilter.POLICY_LABELS_PARTIAL)); ret.setParam(SearchFilter.PLUGIN_HOST_NAME, request.getParameter(SearchFilter.PLUGIN_HOST_NAME)); ret.setParam(SearchFilter.PLUGIN_APP_TYPE, request.getParameter(SearchFilter.PLUGIN_APP_TYPE)); ret.setParam(SearchFilter.PLUGIN_ENTITY_TYPE, request.getParameter(SearchFilter.PLUGIN_ENTITY_TYPE)); ret.setParam(SearchFilter.PLUGIN_IP_ADDRESS, request.getParameter(SearchFilter.PLUGIN_IP_ADDRESS)); ret.setParam(SearchFilter.ZONE_NAME, request.getParameter(SearchFilter.ZONE_NAME)); ret.setParam(SearchFilter.TAG_SERVICE_ID, request.getParameter(SearchFilter.TAG_SERVICE_ID)); ret.setParam(SearchFilter.ROLE_NAME, request.getParameter(SearchFilter.ROLE_NAME)); ret.setParam(SearchFilter.ROLE_ID, request.getParameter(SearchFilter.ROLE_ID)); ret.setParam(SearchFilter.GROUP_NAME, request.getParameter(SearchFilter.GROUP_NAME)); ret.setParam(SearchFilter.USER_NAME, request.getParameter(SearchFilter.USER_NAME)); ret.setParam(SearchFilter.ROLE_NAME_PARTIAL, request.getParameter(SearchFilter.ROLE_NAME_PARTIAL)); ret.setParam(SearchFilter.GROUP_NAME_PARTIAL, request.getParameter(SearchFilter.GROUP_NAME_PARTIAL)); ret.setParam(SearchFilter.USER_NAME_PARTIAL, request.getParameter(SearchFilter.USER_NAME_PARTIAL)); ret.setParam(SearchFilter.CLUSTER_NAME, request.getParameter(SearchFilter.CLUSTER_NAME)); ret.setParam(SearchFilter.FETCH_ZONE_UNZONE_POLICIES, request.getParameter(SearchFilter.FETCH_ZONE_UNZONE_POLICIES)); ret.setParam(SearchFilter.FETCH_TAG_POLICIES, request.getParameter(SearchFilter.FETCH_TAG_POLICIES)); for (Map.Entry<String, String[]> e : request.getParameterMap().entrySet()) { String name = e.getKey(); String[] values = e.getValue(); if (!StringUtils.isEmpty(name) && !ArrayUtils.isEmpty(values) && name.startsWith(SearchFilter.RESOURCE_PREFIX)) { ret.setParam(name, values[0]); } } ret.setParam(SearchFilter.RESOURCE_MATCH_SCOPE, request.getParameter(SearchFilter.RESOURCE_MATCH_SCOPE)); extractCommonCriteriasForFilter(request, ret, sortFields); return ret; }
Example 19
Source File: CraftSound.java From Thermos with GNU General Public License v3.0 | 4 votes |
public static String getSound(final Sound sound) { Validate.notNull(sound, "Sound cannot be null"); return sounds[sound.ordinal()]; }
Example 20
Source File: PermissionsService.java From Slimefun4 with GNU General Public License v3.0 | 2 votes |
/** * This method sets the {@link Permission} for a given {@link SlimefunItem}. * * @param item * The {@link SlimefunItem} to modify * @param permission * The {@link Permission} to set */ public void setPermission(SlimefunItem item, String permission) { Validate.notNull(item, "You cannot set the permission for null"); permissions.put(item.getID(), permission != null ? permission : "none"); }