private void checkClassLoaderId(String classLoaderId) { checkArgument(!StringUtils.isEmpty(classLoaderId), "artifactId cannot be empty"); } }
public static boolean blankAttribute(Element element, String attribute) { return StringUtils.isBlank(element.getAttribute(attribute)); }
public void setEnabledProtocols(String enabledProtocols) { this.enabledProtocols = StringUtils.splitAndTrim(enabledProtocols, ","); }
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (tracking) { ifNotBlank(beanName, value -> { if (!trackingList.contains(value)) { trackingList.add(value); } }); } return bean; }
@Test public void testByteArrayToHexString() { assertNull(StringUtils.toHexString(null)); assertEquals("", StringUtils.toHexString(new byte[] {})); assertEquals("01", StringUtils.toHexString(new byte[] {1})); assertEquals("0102", StringUtils.toHexString(new byte[] {1, 2})); assertEquals("0a0e", StringUtils.toHexString(new byte[] {10, 14})); assertEquals("0A0E", StringUtils.toHexString(new byte[] {10, 14}, true)); assertEquals("0aff", StringUtils.toHexString(new byte[] {10, (byte) 0xff})); assertEquals("0AFF", StringUtils.toHexString(new byte[] {10, (byte) 0xff}, true)); }
@Test public void testHexStringToByteArray() { assertNull(StringUtils.hexStringToByteArray(null)); try { StringUtils.hexStringToByteArray("1"); fail(); } catch (IllegalArgumentException iex) { // OK } assertTrue(Arrays.equals(new byte[] {}, StringUtils.hexStringToByteArray(""))); assertTrue(Arrays.equals(new byte[] {1}, StringUtils.hexStringToByteArray("01"))); assertTrue(Arrays.equals(new byte[] {1, 2}, StringUtils.hexStringToByteArray("0102"))); assertTrue(Arrays.equals(new byte[] {10, 14}, StringUtils.hexStringToByteArray("0A0E"))); assertTrue(Arrays.equals(new byte[] {10, 14}, StringUtils.hexStringToByteArray("0a0e"))); assertTrue(Arrays.equals(new byte[] {10, (byte) 0xff}, StringUtils.hexStringToByteArray("0AFF"))); assertTrue(Arrays.equals(new byte[] {10, (byte) 0xff}, StringUtils.hexStringToByteArray("0aff"))); }
private void parseExternalLib(DeclaresExternalLibraries declarer, ExternalLib externalLibAnnotation) { ExternalLibraryModelBuilder builder = ExternalLibraryModel.builder() .withName(externalLibAnnotation.name()) .withDescription(externalLibAnnotation.description()) .withType(externalLibAnnotation.type()) .isOptional(externalLibAnnotation.optional()); ifNotBlank(externalLibAnnotation.nameRegexpMatcher(), builder::withRegexpMatcher); ifNotBlank(externalLibAnnotation.requiredClassName(), builder::withRequiredClassName); ifNotBlank(externalLibAnnotation.coordinates(), builder::withCoordinates); declarer.withExternalLibrary(builder.build()); }
/** * @see #toHexString(byte[]) */ public static String toHexString(byte[] bytes) { return StringUtils.toHexString(bytes, false); }
@Override protected Object doTransform(Object src, Charset outputEncoding) throws TransformerException { if (src == null) { return ArrayUtils.EMPTY_BYTE_ARRAY; } try { return StringUtils.hexStringToByteArray((String) src); } catch (Exception ex) { throw new TransformerException(this, ex); } }
/** * Registers an object to make it available as a candidate to be injected * * @param key name of the object to be registered * @param value object to register */ protected final void registerObject(String key, Object value) { if (value == null) { return; } checkArgument(!isEmpty(key), "key cannot be empty"); objectsToRegister.put(key, value); }
public static String getNameOrId(Element element) { String id = element.getAttribute(ATTRIBUTE_ID); String name = element.getAttribute(ATTRIBUTE_NAME); if (StringUtils.isBlank(id)) { if (StringUtils.isBlank(name)) { return ""; } else { return name; } } else { if (!StringUtils.isBlank(name) && !name.equals(id)) { logger.warn("Id (" + id + ") and name (" + name + ") differ for " + elementToString(element)); } return id; } }
public void setEnabledCipherSuites(String enabledCipherSuites) { this.enabledCipherSuites = StringUtils.splitAndTrim(enabledCipherSuites, ","); }
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (tracking) { ifNotBlank(beanName, value -> { if (!trackingList.contains(value)) { trackingList.add(value); } }); } return bean; }
@Test public void testByteArrayToHexString() { assertNull(StringUtils.toHexString(null)); assertEquals("", StringUtils.toHexString(new byte[] {})); assertEquals("01", StringUtils.toHexString(new byte[] {1})); assertEquals("0102", StringUtils.toHexString(new byte[] {1, 2})); assertEquals("0a0e", StringUtils.toHexString(new byte[] {10, 14})); assertEquals("0A0E", StringUtils.toHexString(new byte[] {10, 14}, true)); assertEquals("0aff", StringUtils.toHexString(new byte[] {10, (byte) 0xff})); assertEquals("0AFF", StringUtils.toHexString(new byte[] {10, (byte) 0xff}, true)); }
@Test public void testHexStringToByteArray() { assertNull(StringUtils.hexStringToByteArray(null)); try { StringUtils.hexStringToByteArray("1"); fail(); } catch (IllegalArgumentException iex) { // OK } assertTrue(Arrays.equals(new byte[] {}, StringUtils.hexStringToByteArray(""))); assertTrue(Arrays.equals(new byte[] {1}, StringUtils.hexStringToByteArray("01"))); assertTrue(Arrays.equals(new byte[] {1, 2}, StringUtils.hexStringToByteArray("0102"))); assertTrue(Arrays.equals(new byte[] {10, 14}, StringUtils.hexStringToByteArray("0A0E"))); assertTrue(Arrays.equals(new byte[] {10, 14}, StringUtils.hexStringToByteArray("0a0e"))); assertTrue(Arrays.equals(new byte[] {10, (byte) 0xff}, StringUtils.hexStringToByteArray("0AFF"))); assertTrue(Arrays.equals(new byte[] {10, (byte) 0xff}, StringUtils.hexStringToByteArray("0aff"))); }
/** * Returns the file for a given service name. * * @param name name of the service. Non empty. * @return a {@link File} pointing to the folder that corresponds to the provided service name when installed. */ public static File getServiceFolder(String name) { checkArgument(!StringUtils.isEmpty(name), "name cannot be empty"); return new File(getServicesFolder(), name); }
public MediaTypeModelProperty(String mimeType, boolean strict) { mediaType = isBlank(mimeType) ? null : MediaType.parse(mimeType); this.strict = strict; }
@Test public void testSplitAndTrim2() { String[] inputValues = new String[] {"foo", "bar", "baz", "kaboom"}; String inputString = new StringBuilder(40).append(inputValues[0]).append(" ,").append(", ").append(inputValues[1]) .append(" ,").append(inputValues[2]).append(" , ").append(inputValues[3]).append(" ").toString(); assertTrue(Arrays.equals(inputValues, StringUtils.splitAndTrim(inputString, ","))); }
private void parseExternalLib(DeclaresExternalLibraries declarer, ExternalLib externalLibAnnotation) { ExternalLibraryModelBuilder builder = ExternalLibraryModel.builder() .withName(externalLibAnnotation.name()) .withDescription(externalLibAnnotation.description()) .withType(externalLibAnnotation.type()) .isOptional(externalLibAnnotation.optional()); ifNotBlank(externalLibAnnotation.nameRegexpMatcher(), builder::withRegexpMatcher); ifNotBlank(externalLibAnnotation.requiredClassName(), builder::withRequiredClassName); ifNotBlank(externalLibAnnotation.coordinates(), builder::withCoordinates); declarer.withExternalLibrary(builder.build()); }
@Override protected Object doTransform(Object src, Charset encoding) throws TransformerException { if (src == null) { return StringUtils.EMPTY; } try { byte[] bytes = null; if (src instanceof CursorStreamProvider) { bytes = handleStream(((CursorStreamProvider) src).openCursor()); } else if (src instanceof InputStream) { bytes = handleStream((InputStream) src); } else { bytes = (byte[]) src; } return StringUtils.toHexString(bytes, upperCase); } catch (Exception ex) { throw new TransformerException(this, ex); } }