List of usage examples for java.util List toArray
<T> T[] toArray(T[] a);
From source file:cz.lbenda.coursing.user.UserRole.java
public static UserRole[] toArray(String roles) { List<UserRole> result = new ArrayList<>(); if (roles == null || "".equals(roles.trim())) { return new UserRole[0]; }//from ww w . j ava 2 s . com for (String role : roles.split(",")) { result.add(UserRole.valueOf(role.trim())); } return result.toArray(new UserRole[result.size()]); }
From source file:au.org.ala.delta.intkey.ui.IntKeyDialogController.java
private static IntkeyDialog[] getVisibleWindows() { List<IntkeyDialog> temp = new ArrayList<IntkeyDialog>(); for (IntkeyDialog dlg : DIALOGS) { if (dlg.isVisible()) { temp.add(dlg);// ww w . j ava2 s. co m dlg.toFront(); } } return temp.toArray(new IntkeyDialog[] {}); }
From source file:springfox.documentation.schema.property.bean.BeanModelProperty.java
private static ResolvedType adjustedToClassmateBug(TypeResolver typeResolver, ResolvedType resolvedType) { if (resolvedType.getErasedType().getTypeParameters().length > 0) { List<ResolvedType> typeParms = newArrayList(); for (ResolvedType each : resolvedType.getTypeParameters()) { typeParms.add(adjustedToClassmateBug(typeResolver, each)); }//from ww w .jav a 2s . c o m return typeResolver.resolve(resolvedType, typeParms.toArray(new Type[typeParms.size()])); } else { return typeResolver.resolve(resolvedType.getErasedType()); } }
From source file:Main.java
static <E> List<E> getList(List<E> orig, Class<E> elemType) { if (orig == null || orig.isEmpty()) { return Collections.emptyList(); } else if (orig.size() == 1) { return Collections.singletonList(orig.get(0)); } else {/*from ww w . ja v a 2 s .c o m*/ return Collections.unmodifiableList(Arrays.asList(orig.toArray(createArray(elemType, orig.size())))); } }
From source file:me.st28.flexseries.flexcore.util.ChatColorUtils.java
/** * Basically ChatColor.translateAlternateColorCodes on a string array. * * @param altColorChar Code to use.// www . java 2 s .com * @param arrayToTranslate String array to format. * @return Newly formatted string array. */ public static String[] translateAlternateColorCodes(char altColorChar, String[] arrayToTranslate) { List<String> returnList = new ArrayList<>(); for (String string : arrayToTranslate) { returnList.add(ChatColor.translateAlternateColorCodes(altColorChar, string)); } return returnList.toArray(new String[returnList.size()]); }
From source file:com.indeed.imhotep.web.config.PropertiesInitializer.java
private static void activateSpringProfiles(ConfigurableEnvironment springEnv) { if (IQLEnv.isSpringProfileSet(springEnv)) { return; // we seem to already have some profile set. let it be }/*from w w w .j a va2 s . c o m*/ // try to infer the appropriate Spring profile // this JVM system property should be set in OPs managed JVMs String indeedEnv = System.getProperty(indeedEnvironmentJVMProperty); if (Strings.isNullOrEmpty(indeedEnv)) { indeedEnv = "developer"; // assume this is not an OPs managed JVM and thus a developer station } final List<String> profiles = Lists.newArrayList(springEnv.getActiveProfiles()); profiles.add(indeedEnv); springEnv.setActiveProfiles(profiles.toArray(new String[profiles.size()])); }
From source file:com.kelveden.rastajax.cli.Runner.java
private static String mediaTypesToString(final String header, final List<String> mediaTypes) { if (mediaTypes.size() == 0) { return null; } else {/* ww w.j a va 2s. c om*/ return SUB_SUB_TEXT_PADDING + header + StringUtils.join(mediaTypes.toArray(new String[mediaTypes.size()]), ", "); } }
From source file:com.cassius.spring.assembly.test.common.toolbox.LogFormatUtil.java
/** * Format string.// www.j av a 2s.co m * * @param message the message * @param logs the logs * @return the string */ public static String format(String message, String[] logs) { List<String> stringSet = new ArrayList<String>(); stringSet.add(message); stringSet.addAll(Arrays.asList(logs)); String[] result = new String[stringSet.size()]; result = stringSet.toArray(result); return format(result); }
From source file:com.netflix.genie.core.jpa.specifications.JpaApplicationSpecs.java
/** * Get a specification using the specified parameters. * * @param name The name of the application * @param user The name of the user who created the application * @param statuses The status of the application * @param tags The set of tags to search the command for * @param type The type of applications to fine * @return A specification object used for querying */// ww w.jav a 2 s. c o m public static Specification<ApplicationEntity> find(final String name, final String user, final Set<ApplicationStatus> statuses, final Set<String> tags, final String type) { return (final Root<ApplicationEntity> root, final CriteriaQuery<?> cq, final CriteriaBuilder cb) -> { final List<Predicate> predicates = new ArrayList<>(); if (StringUtils.isNotBlank(name)) { predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb, root.get(ApplicationEntity_.name), name)); } if (StringUtils.isNotBlank(user)) { predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb, root.get(ApplicationEntity_.user), user)); } if (statuses != null && !statuses.isEmpty()) { final List<Predicate> orPredicates = statuses.stream() .map(status -> cb.equal(root.get(ApplicationEntity_.status), status)) .collect(Collectors.toList()); predicates.add(cb.or(orPredicates.toArray(new Predicate[orPredicates.size()]))); } if (tags != null && !tags.isEmpty()) { predicates.add( cb.like(root.get(ApplicationEntity_.tags), JpaSpecificationUtils.getTagLikeString(tags))); } if (StringUtils.isNotBlank(type)) { predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb, root.get(ApplicationEntity_.type), type)); } return cb.and(predicates.toArray(new Predicate[predicates.size()])); }; }
From source file:com.mirth.connect.connectors.dimse.DICOMConfigurationUtil.java
public static void configureDcmRcv(MirthDcmRcv dcmrcv, DICOMReceiver connector, DICOMReceiverProperties connectorProperties, String[] protocols) throws Exception { if (!StringUtils.equals(connectorProperties.getTls(), "notls")) { if (connectorProperties.getTls().equals("without")) { dcmrcv.setTlsWithoutEncyrption(); } else if (connectorProperties.getTls().equals("3des")) { dcmrcv.setTls3DES_EDE_CBC(); } else if (connectorProperties.getTls().equals("aes")) { dcmrcv.setTlsAES_128_CBC();//from ww w . ja va2 s.com } String trustStore = connector.getReplacer().replaceValues(connectorProperties.getTrustStore(), connector.getChannelId(), connector.getChannel().getName()); if (StringUtils.isNotBlank(trustStore)) { dcmrcv.setTrustStoreURL(trustStore); } String trustStorePW = connector.getReplacer().replaceValues(connectorProperties.getTrustStorePW(), connector.getChannelId(), connector.getChannel().getName()); if (StringUtils.isNotBlank(trustStorePW)) { dcmrcv.setTrustStorePassword(trustStorePW); } String keyPW = connector.getReplacer().replaceValues(connectorProperties.getKeyPW(), connector.getChannelId(), connector.getChannel().getName()); if (StringUtils.isNotBlank(keyPW)) { dcmrcv.setKeyPassword(keyPW); } String keyStore = connector.getReplacer().replaceValues(connectorProperties.getKeyStore(), connector.getChannelId(), connector.getChannel().getName()); if (StringUtils.isNotBlank(keyStore)) { dcmrcv.setKeyStoreURL(keyStore); } String keyStorePW = connector.getReplacer().replaceValues(connectorProperties.getKeyStorePW(), connector.getChannelId(), connector.getChannel().getName()); if (StringUtils.isNotBlank(keyStorePW)) { dcmrcv.setKeyStorePassword(keyStorePW); } dcmrcv.setTlsNeedClientAuth(connectorProperties.isNoClientAuth()); protocols = ArrayUtils.clone(protocols); if (connectorProperties.isNossl2()) { if (ArrayUtils.contains(protocols, "SSLv2Hello")) { List<String> protocolsList = new ArrayList<String>(Arrays.asList(protocols)); protocolsList.remove("SSLv2Hello"); protocols = protocolsList.toArray(new String[protocolsList.size()]); } } else if (!ArrayUtils.contains(protocols, "SSLv2Hello")) { List<String> protocolsList = new ArrayList<String>(Arrays.asList(protocols)); protocolsList.add("SSLv2Hello"); protocols = protocolsList.toArray(new String[protocolsList.size()]); } dcmrcv.setTlsProtocol(MirthSSLUtil.getEnabledHttpsProtocols(protocols)); dcmrcv.initTLS(); } }