List of usage examples for org.apache.commons.lang3 ArrayUtils isEmpty
public static boolean isEmpty(final boolean[] array)
Checks if an array of primitive booleans is empty or null .
From source file:com.jkoolcloud.tnt4j.streams.sample.builder.SampleStreamingApp.java
/** * Main entry point for running as a standalone application. * * @param args/*from w w w . j av a 2 s . co m*/ * program command-line arguments. Supported arguments: * <table summary="TNT4J-Streams agent command line arguments"> * <tr> * <td> </td> * <td> <orders_log_file_path></td> * <td>(optional) path of "orders.log" file. Default value is working dir.</td> * </tr> * </table> * @throws Exception * if any exception occurs while running application */ public static void main(String... args) throws Exception { Map<String, String> props = new HashMap<>(); props.put(ParserProperties.PROP_FLD_DELIM, "|"); // NON-NLS ActivityTokenParser atp = new ActivityTokenParser(); atp.setName("TokenParser"); // NON-NLS atp.setProperties(props.entrySet()); ActivityField f = new ActivityField(StreamFieldType.StartTime.name()); ActivityFieldLocator afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "1"); afl.setFormat("dd MMM yyyy HH:mm:ss", "en-US"); // NON-NLS f.addLocator(afl); atp.addField(f); f = new ActivityField(StreamFieldType.ServerIp.name()); afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "2"); f.addLocator(afl); atp.addField(f); f = new ActivityField(StreamFieldType.ApplName.name()); afl = new ActivityFieldLocator("orders"); // NON-NLS f.addLocator(afl); atp.addField(f); f = new ActivityField(StreamFieldType.Correlator.name()); afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "3"); f.addLocator(afl); atp.addField(f); f = new ActivityField(StreamFieldType.UserName.name()); afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "4"); f.addLocator(afl); atp.addField(f); f = new ActivityField(StreamFieldType.EventName.name()); afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "5"); f.addLocator(afl); atp.addField(f); f = new ActivityField(StreamFieldType.EventType.name()); afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "5"); afl.addValueMap("Order Placed", "START").addValueMap("Order Received", "RECEIVE") // NON-NLS .addValueMap("Order Processing", "OPEN").addValueMap("Order Processed", "SEND") // NON-NLS .addValueMap("Order Shipped", "END"); // NON-NLS f.addLocator(afl); atp.addField(f); f = new ActivityField("MsgValue"); // NON-NLS afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "8"); f.addLocator(afl); atp.addField(f); props = new HashMap<>(); props.put(StreamProperties.PROP_FILENAME, ArrayUtils.isEmpty(args) ? "orders.log" : args[0]); // NON-NLS FileLineStream fls = new FileLineStream(); fls.setName("FileStream"); // NON-NLS fls.setProperties(props.entrySet()); fls.addParser(atp); // if (fls.getOutput() == null) { // fls.setDefaultStreamOutput(); // } StreamsAgent.runFromAPI(fls); }
From source file:com.mseeworld.qzh.util.Debug.java
/** * ?//from www . j a v a2 s . c o m * @param objects * @date 2013-5-8 */ public static final void printf(String msg, Object... objects) { if (ArrayUtils.isEmpty(objects)) { System.out.println(msg); return; } for (int i = 0, len = objects.length; i < len; i++) { Object obj = objects[i]; msg = msg.replaceFirst("\\{\\}", obj == null ? "" : obj.toString()); } System.out.println(msg); }
From source file:de.jcup.egradle.core.domain.GradleCommand.java
public static GradleCommand[] build(GradleSubproject gradleSubproject, String commandString) { notNull(commandString);/*from www. ja va 2s . co m*/ String[] commands = commandString.split(" "); if (ArrayUtils.isEmpty(commands)) { return new GradleCommand[] {}; } List<GradleCommand> list = new ArrayList<>(); for (int i = 0; i < commands.length; i++) { String command = commands[i]; List<String> param = null; /* * check if following is an argument (e.g. test --tests * de.jcup.MyTestClass */ if (i + 2 < commands.length) { String potentialArg = commands[i + 1]; if (potentialArg.startsWith("--")) { /* argument detected */ param = new ArrayList<>(); param.add(potentialArg); param.add(commands[i + 2]); i = i + 2; } } list.add(new GradleCommand(gradleSubproject, command, param)); } return list.toArray(new GradleCommand[list.size()]); }
From source file:io.syndesis.credential.CredentialFlowStateHelper.java
static Set<CredentialFlowState> restoreFrom(final Restorer restore, final HttpServletRequest request) { final Cookie[] servletCookies = request.getCookies(); if (ArrayUtils.isEmpty(servletCookies)) { return Collections.emptySet(); }/*from w ww.j a v a 2 s . co m*/ final List<javax.ws.rs.core.Cookie> credentialCookies = Arrays.stream(servletCookies) .filter(c -> c.getName().startsWith(CredentialFlowState.CREDENTIAL_PREFIX)) .map(CredentialFlowStateHelper::toJaxRsCookie).collect(Collectors.toList()); try { return restore.apply(credentialCookies, CredentialFlowState.class); } catch (final IllegalArgumentException e) { return Collections.emptySet(); } }
From source file:com.jim.im.utils.ImUtils.java
/** * ??int//from w ww .j av a 2s . c om * * @param sources * @throws ImParamException */ public static Integer[] transferString2Int(String[] sources, String errorMsg) throws ImParamException { Integer[] result = ArrayUtils.isEmpty(sources) ? new Integer[0] : new Integer[sources.length]; try { for (int index = 0; index < result.length; index++) { result[index] = Integer.valueOf(sources[index]); } } catch (NumberFormatException e) { ImParamExceptionAssert.check(false, errorMsg); } return result; }
From source file:com.nesscomputing.mojo.numbers.DateField.java
public static List<DateField> createDates(final PropertyCache propertyCache, final DateDefinition[] dateDefinitions) throws IOException { final List<DateField> result = Lists.newArrayList(); if (!ArrayUtils.isEmpty(dateDefinitions)) { for (DateDefinition dateDefinition : dateDefinitions) { dateDefinition.check();/* ww w . j a v a 2 s. c o m*/ final ValueProvider dateValue = propertyCache.getPropertyValue(dateDefinition); final DateField dateField = new DateField(dateDefinition, dateValue); result.add(dateField); } } return result; }
From source file:com.nesscomputing.mojo.numbers.StringField.java
public static List<StringField> createStrings(final PropertyCache propertyCache, final StringDefinition[] stringDefinitions) throws IOException { final List<StringField> result = Lists.newArrayList(); if (!ArrayUtils.isEmpty(stringDefinitions)) { for (StringDefinition stringDefinition : stringDefinitions) { stringDefinition.check();/* www.j av a 2s . c o m*/ final ValueProvider stringValue = propertyCache.getPropertyValue(stringDefinition); final StringField stringField = new StringField(stringDefinition, stringValue); result.add(stringField); } } return result; }
From source file:com.nesscomputing.mojo.numbers.MacroField.java
public static List<MacroField> createMacros(final PropertyCache propertyCache, final MacroDefinition[] macroDefinitions, final AbstractNumbersMojo mojo) throws IOException { final List<MacroField> result = Lists.newArrayList(); if (!ArrayUtils.isEmpty(macroDefinitions)) { for (MacroDefinition macroDefinition : macroDefinitions) { macroDefinition.check();/* w w w .j a va 2 s. com*/ final ValueProvider macroValue = propertyCache.getPropertyValue(macroDefinition); final MacroField macroField = new MacroField(macroDefinition, macroValue, mojo); result.add(macroField); } } return result; }
From source file:jp.furplag.spring.booster.validation.tuple.PairNumbers.java
/** * Checks whether the objects a valid pair of numbers. * * @param left the object to try parsing to a number. * @param right the object to try parsing to a number. * @return returns true if the objects parsable to a number. *///from w ww. ja va 2 s .com public static boolean isCreatable(Object left, Object right, Class<?>... classes) { if (ArrayUtils.isEmpty(classes)) return isCollectable(left) && isCollectable(right); return isNumberOf(left, classes) && isNumberOf(right, classes); }
From source file:co.runrightfast.vertx.core.eventbus.MessageHandler.java
/** * * @param <MSG> Message payload type * @param messageProcessor1 the first processor in the chain * @param messageProcessor2 the second processor in the chain * @param chain optional - the rest of the chain * @return handler/*from ww w .j a va 2s . c om*/ */ static <MSG extends com.google.protobuf.Message> Handler<Message<MSG>> composeHandler( @NonNull final MessageHandler<MSG> messageProcessor1, @NonNull final MessageHandler<MSG> messageProcessor2, final MessageHandler<MSG>... chain) { if (ArrayUtils.isEmpty(chain)) { return message -> messageProcessor1.andThen(messageProcessor2).apply(message); } final Function<Message<MSG>, Message<MSG>> composedProcessor = Arrays.stream(chain).sequential().reduce( messageProcessor1.andThen(messageProcessor2), (p1, p2) -> p1.andThen(p2), (p1, p2) -> p1.andThen(p2)); return message -> composedProcessor.apply(message); }