if (Strings.isNotEmpty(logName)) { sb.append(logName); sb.append(SPACE);
.append(" results check failed with error code ") .append(result.getReturnCode()); if (Strings.isNotEmpty(result.getCapturedOutput())) { builder.append(" and diff value ").append(result.getCapturedOutput());
.append(" results check failed with error code ") .append(result.getReturnCode()); if (Strings.isNotEmpty(result.getCapturedOutput())) { builder.append(" and diff value ").append(result.getCapturedOutput());
boolean discard() { if (discardIfEmpty == false) { return false; } boolean foundNotEmptyValue = false; for (final Map.Entry<String, String> entry : fields.entrySet()) { if (Strings.isNotEmpty(entry.getValue())) { foundNotEmptyValue = true; break; } } return !foundNotEmptyValue; }
private void handle(GetKVMHostDownloadCredentialMsg msg) { final GetKVMHostDownloadCredentialReply reply = new GetKVMHostDownloadCredentialReply(); String key = asf.getPrivateKey(); String hostname = null; if (Strings.isNotEmpty(msg.getDataNetworkCidr())) { String dataNetworkAddress = getDataNetworkAddress(self.getUuid(), msg.getDataNetworkCidr()); if (dataNetworkAddress != null) { hostname = dataNetworkAddress; } } reply.setHostname(hostname == null ? getSelf().getManagementIp() : hostname); reply.setUsername(getSelf().getUsername()); reply.setSshPort(getSelf().getPort()); reply.setSshKey(key); bus.reply(msg, reply); }
private static List<Object> replaceChildren(String locator) { List<Object> result = new ArrayList<>(); String loc = locator; Matcher m = Pattern.compile("\\[(?<num>\\d+)]").matcher(loc); while (m.find() && isNotEmpty(loc)) { String[] locs = loc.split("\\["+m.group("num")+"]"); if (locs.length > 0) result.add(By.cssSelector(locs[0])); result.add(Integer.parseInt(m.group("num"))); loc = locs.length == 2 ? locs[1] : ""; } if (isNotEmpty(loc)) result.add(By.cssSelector(loc)); return result; }
private static List<By> replaceText(String locator) { List<By> result = new ArrayList<>(); String loc = locator; Matcher m = Pattern.compile("\\[(?<modifier>\\*?)'(?<text>[^']+)']").matcher(loc); while (m.find() && isNotEmpty(loc)) { String[] locs = loc.split("\\[\\*?'"+m.group("text")+"']"); if (locs.length > 0) result.add(By.cssSelector(locs[0])); result.add(m.group("modifier").equals("") ? By.xpath(".//*[text()='" + m.group("text") + "']") : By.xpath(".//*[contains(text(),'" + m.group("text") + "')]")); loc = locs.length == 2 ? locs[1] : ""; } if (isNotEmpty(loc)) result.add(By.cssSelector(loc)); return result; }
private static List<By> replaceUp(String locator) { List<By> result = null; if (locator.contains("<")) { result = new ArrayList<>(); String loc = locator.replaceAll(" *< *", "<"); Matcher m = Pattern.compile("(?<up><+)").matcher(loc); while (m.find()) { String[] locs = loc.split(m.group("up")); if (locs.length > 0) result.add(By.cssSelector(locs[0])); result.add(getUpXpath(m.group("up"))); loc = locs.length == 2 ? locs[1] : ""; } if (isNotEmpty(loc)) result.add(By.cssSelector(loc)); } return valueOrDefault(result, asList(By.cssSelector(locator))); } private static By getUpXpath(String group) {
public void generateScript(String packageStr, String dialect, String filename){ Set<Class<?>> typesAnnotatedWith = SingularClassPathScanner.get().findClassesAnnotatedWith(Entity.class); List<Class<?>> list = typesAnnotatedWith.stream().filter(c -> Strings.isNotEmpty(packageStr) ? c.getPackage().getName().startsWith(packageStr) : true ).collect(Collectors.toList()); //create a minimal configuration Configuration cfg = new Configuration(); cfg.setProperty("hibernate.dialect",Strings.isNotEmpty(dialect)? dialect: H2 ); cfg.setProperty("hibernate.hbm2ddl.auto", "create"); for(Class<?> c : list){ cfg.addAnnotatedClass(c); } //build all the mappings, before calling the AuditConfiguration cfg.buildMappings(); //execute the export org.hibernate.tool.hbm2ddl.SchemaExport export = new org.hibernate.tool.hbm2ddl.SchemaExport(cfg); export.setOutputFile(Strings.isNotEmpty(filename)? filename: SCRIPT_FILE); export.setDelimiter(";"); export.setFormat(true); export.execute(true, false, false, true); }
public void generateScript(String packageStr, String dialect, String filename) { Set<Class<?>> typesAnnotatedWith = SingularClassPathScanner.get().findClassesAnnotatedWith(Entity.class); List<Class<?>> list = typesAnnotatedWith.stream().filter(c -> Strings.isNotEmpty(packageStr) ? c.getPackage().getName().startsWith(packageStr) : true ).collect(Collectors.toList()); //create a minimal configuration Configuration cfg = new Configuration(); cfg.setProperty("hibernate.dialect", Strings.isNotEmpty(dialect) ? dialect : H2); cfg.setProperty("hibernate.hbm2ddl.auto", "create"); for (Class<?> c : list) { cfg.addAnnotatedClass(c); } //build all the mappings, before calling the AuditConfiguration cfg.buildMappings(); //execute the export org.hibernate.tool.hbm2ddl.SchemaExport export = new org.hibernate.tool.hbm2ddl.SchemaExport(cfg); export.setOutputFile(Strings.isNotEmpty(filename) ? filename : SCRIPT_FILE); export.setDelimiter(";"); export.setFormat(true); export.execute(true, false, false, true); }
private Configuration getConfiguration(final LoggerContext loggerContext, final boolean isTest, final String name) { final boolean named = Strings.isNotEmpty(name); final ClassLoader loader = LoaderUtil.getThreadContextClassLoader(); for (final ConfigurationFactory factory : getFactories()) { String configName; final String prefix = isTest ? TEST_PREFIX : DEFAULT_PREFIX; final String [] types = factory.getSupportedTypes(); if (types == null) { continue; } for (final String suffix : types) { if (suffix.equals(ALL_TYPES)) { continue; } configName = named ? prefix + name + suffix : prefix + suffix; final ConfigurationSource source = ConfigurationSource.fromResource(configName, loader); if (source != null) { if (!factory.isActive()) { LOGGER.warn("Found configuration file {} for inactive ConfigurationFactory {}", configName, factory.getClass().getName()); } return factory.getConfiguration(loggerContext, source); } } } return null; }
@Override public Object visit(final Configuration configuration, final Node node, final LogEvent event, final StringBuilder log) { final String name = this.annotation.value(); final String elementValue = node.getValue(); final String attributeValue = node.getAttributes().get("value"); String rawValue = null; // if neither is specified, return null (LOG4J2-1313) if (Strings.isNotEmpty(elementValue)) { if (Strings.isNotEmpty(attributeValue)) { LOGGER.error("Configuration contains {} with both attribute value ({}) AND element" + " value ({}). Please specify only one value. Using the element value.", node.getName(), attributeValue, elementValue); } rawValue = elementValue; } else { rawValue = removeAttributeValue(node.getAttributes(), "value"); } final String value = this.substitutor.replace(event, rawValue); StringBuilders.appendKeyDqValue(log, name, value); return value; } }
final boolean isPattern = Strings.isNotEmpty(pattern); final boolean isLiteralValue = Strings.isNotEmpty(literal);
@PluginFactory public static GelfLogField createField(@PluginConfiguration final Configuration config, @PluginAttribute("name") String name, @PluginAttribute("literal") String literalValue, @PluginAttribute("mdc") String mdc, @PluginAttribute("pattern") String pattern) { final boolean isPattern = Strings.isNotEmpty(pattern); final boolean isLiteralValue = Strings.isNotEmpty(literalValue); final boolean isMDC = Strings.isNotEmpty(mdc); if (Strings.isEmpty(name)) { LOGGER.error("The name is empty"); return null; } if ((isPattern && isLiteralValue) || (isPattern && isMDC) || (isLiteralValue && isMDC)) { LOGGER.error("The pattern, literal, and mdc attributes are mutually exclusive."); return null; } if (isPattern) { PatternLayout patternLayout = newBuilder().withPattern(pattern).withConfiguration(config) .withNoConsoleNoAnsi(false).withAlwaysWriteExceptions(false).build(); return new GelfLogField(name, null, null, patternLayout); } return new GelfLogField(name, literalValue, mdc, null); } }
@PluginFactory public static GelfLogField createField(@PluginConfiguration final Configuration config, @PluginAttribute("name") String name, @PluginAttribute("literal") String literalValue, @PluginAttribute("mdc") String mdc, @PluginAttribute("pattern") String pattern) { final boolean isPattern = Strings.isNotEmpty(pattern); final boolean isLiteralValue = Strings.isNotEmpty(literalValue); final boolean isMDC = Strings.isNotEmpty(mdc); if (Strings.isEmpty(name)) { LOGGER.error("The name is empty"); return null; } if ((isPattern && isLiteralValue) || (isPattern && isMDC) || (isLiteralValue && isMDC)) { LOGGER.error("The pattern, literal, and mdc attributes are mutually exclusive."); return null; } if (isPattern) { PatternLayout patternLayout = newBuilder().withPattern(pattern).withConfiguration(config) .withNoConsoleNoAnsi(false).withAlwaysWriteExceptions(false).build(); return new GelfLogField(name, null, null, patternLayout); } return new GelfLogField(name, literalValue, mdc, null); } }
@PluginFactory public static GelfLogField createField(@PluginConfiguration final Configuration config, @PluginAttribute("name") String name, @PluginAttribute("literal") String literalValue, @PluginAttribute("mdc") String mdc, @PluginAttribute("pattern") String pattern) { final boolean isPattern = Strings.isNotEmpty(pattern); final boolean isLiteralValue = Strings.isNotEmpty(literalValue); final boolean isMDC = Strings.isNotEmpty(mdc); if (Strings.isEmpty(name)) { LOGGER.error("The name is empty"); return null; } if ((isPattern && isLiteralValue) || (isPattern && isMDC) || (isLiteralValue && isMDC)) { LOGGER.error("The pattern, literal, and mdc attributes are mutually exclusive."); return null; } if (isPattern) { PatternLayout patternLayout = newBuilder().withPattern(pattern).withConfiguration(config) .withNoConsoleNoAnsi(false).withAlwaysWriteExceptions(false).build(); return new GelfLogField(name, null, null, patternLayout); } return new GelfLogField(name, literalValue, mdc, null); } }
if (version != null && isNotEmpty(version)) { query.join(qLifecycleEntity.versionEntity, qVersionEntity); query.where(qVersionEntity.name.eq(version)); qApplicationEntity.id); if (version != null && isNotEmpty(version)) { query.groupBy(qVersionEntity.id);
if (Strings.isNotEmpty(field.getMdc())) { mdcGelfMessageAssembler.addField(new MdcMessageField(field.getName(), field.getMdc())); if (Strings.isNotEmpty(field.getLiteral())) { mdcGelfMessageAssembler.addField(new StaticMessageField(field.getName(), field.getLiteral()));
if (Strings.isNotEmpty(field.getMdc())) { mdcGelfMessageAssembler.addField(new MdcMessageField(field.getName(), field.getMdc())); if (Strings.isNotEmpty(field.getLiteral())) { mdcGelfMessageAssembler.addField(new StaticMessageField(field.getName(), field.getLiteral()));
if (Strings.isNotEmpty(field.getMdc())) { mdcGelfMessageAssembler.addField(new MdcMessageField(field.getName(), field.getMdc())); if (Strings.isNotEmpty(field.getLiteral())) { mdcGelfMessageAssembler.addField(new StaticMessageField(field.getName(), field.getLiteral()));