/** * Converts a Scala List to an Array. */ public static <T> T[] asArray(Class<T> clazz, scala.collection.Seq<T> scalaList) { T[] arr = (T[]) Array.newInstance(clazz, scalaList.length()); scalaList.copyToArray(arr); return arr; }
/** * Converts a Scala List to an Array. * * @param clazz the element class type * @param scalaList the scala list. * @param <T> the return type. * @return the array */ public static <T> T[] asArray(Class<T> clazz, scala.collection.Seq<T> scalaList) { T[] arr = (T[]) Array.newInstance(clazz, scalaList.length()); scalaList.copyToArray(arr); return arr; }
/** * Converts a Scala List to an Array. * * @param clazz the element class type * @param scalaList the scala list. * @param <T> the return type. * @return the array */ public static <T> T[] asArray(Class<T> clazz, scala.collection.Seq<T> scalaList) { T[] arr = (T[]) Array.newInstance(clazz, scalaList.length()); scalaList.copyToArray(arr); return arr; }
/** * Converts a Scala List to an Array. * * @param clazz the element class type * @param scalaList the scala list. * @param <T> the return type. * @return the array */ public static <T> T[] asArray(Class<T> clazz, scala.collection.Seq<T> scalaList) { T[] arr = (T[]) Array.newInstance(clazz, scalaList.length()); scalaList.copyToArray(arr); return arr; }
/** * Converts a Scala List to an Array. */ public static <T> T[] asArray(Class<T> clazz, scala.collection.Seq<T> scalaList) { T[] arr = (T[]) Array.newInstance(clazz, scalaList.length()); scalaList.copyToArray(arr); return arr; }
public static String getBrokers(String zkUrl, SecurityProtocol securityProtocol) { ZkUtils zkUtils = getZkUtils(zkUrl); Seq<Broker> brokersSeq = zkUtils.getAllBrokersInCluster(); Broker[] brokers = new Broker[brokersSeq.size()]; brokersSeq.copyToArray(brokers); String brokersStr = Arrays.stream(brokers) .map(b -> b.brokerEndPoint( ListenerName.forSecurityProtocol(securityProtocol)).connectionString()) .reduce(null, (a, b) -> (a == null) ? b : a + "," + b); return brokersStr; }
public static String getBrokers(String zkUrl, SecurityProtocol securityProtocol) { ZkUtils zkUtils = getZkUtils(zkUrl); Seq<Broker> brokersSeq = zkUtils.getAllBrokersInCluster(); Broker[] brokers = new Broker[brokersSeq.size()]; brokersSeq.copyToArray(brokers); String brokersStr = Arrays.stream(brokers) .map(b -> b.brokerEndPoint( ListenerName.forSecurityProtocol(securityProtocol)).connectionString()) .reduce(null, (a, b) -> (a == null) ? b : a + "," + b); return brokersStr; }
/** * We retrieve the body apart from the request. Otherwise, there is an issue in casting the body between Scala and Java. * * @param requestHeader the request without the body * @param body the body (maybe) * @param sessionStore the session store */ public PlayWebContext(final RequestHeader requestHeader, final Object body, final SessionStore<org.pac4j.play.PlayWebContext> sessionStore) { this(JavaHelpers$.MODULE$.createJavaContext(requestHeader, JavaHelpers$.MODULE$.createContextComponents()), sessionStore); this.formParameters = new HashMap<>(); if (body instanceof AnyContentAsFormUrlEncoded) { final scala.collection.immutable.Map<String, Seq<String>> parameters = ((AnyContentAsFormUrlEncoded) body).asFormUrlEncoded().get(); for (final String key : ScalaCompatibility.scalaSetToJavaSet(parameters.keySet())) { final Seq<String> v = parameters.get(key).get(); final String[] values = new String[v.size()]; v.copyToArray(values); formParameters.put(key, values); } } }
/** * We retrieve the body apart from the request. Otherwise, there is an issue in casting the body between Scala and Java. * * @param requestHeader the request without the body * @param body the body (maybe) * @param sessionStore the session store */ public PlayWebContext(final RequestHeader requestHeader, final Object body, final SessionStore<org.pac4j.play.PlayWebContext> sessionStore) { this(JavaHelpers$.MODULE$.createJavaContext(requestHeader, JavaHelpers$.MODULE$.createContextComponents()), sessionStore); this.formParameters = new HashMap<>(); if (body instanceof AnyContentAsFormUrlEncoded) { final scala.collection.immutable.Map<String, Seq<String>> parameters = ((AnyContentAsFormUrlEncoded) body).asFormUrlEncoded().get(); for (final String key : ScalaCompatibility.scalaSetToJavaSet(parameters.keySet())) { final Seq<String> v = parameters.get(key).get(); final String[] values = new String[v.size()]; v.copyToArray(values); formParameters.put(key, values); } } }