@Override public void setListener(Listener listener) { Assert.notNull(listener, "The stream listener must be not null"); this.listener = listener; }
public FlexContext(Request request, Stream stream, FlexConnection connection) { Assert.notNull(request, "The request must be not null."); this.request = request; this.connection = connection; this.stream = stream; }
@Override public void setListener(Listener listener) { Assert.notNull(listener, "The session listener must be not null"); this.listener = listener; }
/** * Create a new PathResource from a Path handle. * <p>Note: Unlike {@link FileSystemResource}, when building relative resources * via {@link #createRelative}, the relative path will be built <i>underneath</i> * the given root: * e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"! * @param path a Path handle */ public PathResource(Path path) { Assert.notNull(path, "Path must not be null"); this.path = path.normalize(); }
/** * Convert a "/"-based resource path to a "."-based fully qualified class name. * @param resourcePath the resource path pointing to a class * @return the corresponding fully qualified class name */ public static String convertResourcePathToClassName(String resourcePath) { Assert.notNull(resourcePath, "Resource path must not be null"); return resourcePath.replace(PATH_SEPARATOR, PACKAGE_SEPARATOR); }
public FlexOutputStream(MetaInfo metaInfo, Stream stream, MetaInfoGenerator metaInfoGenerator, boolean committed) { Assert.notNull(metaInfo, "The meta info must be not null"); Assert.notNull(stream, "The stream must be not null"); this.metaInfo = metaInfo; this.stream = stream; this.metaInfoGenerator = Optional.ofNullable(metaInfoGenerator).orElse(MetaInfoGenerator.DEFAULT); this.committed = committed; }
/** * Resolve the given class if it is a primitive class, * returning the corresponding primitive wrapper type instead. * * @param clazz the class to check * @return the original class, or a primitive wrapper for the original primitive type */ public static Class<?> resolvePrimitiveIfNecessary(Class<?> clazz) { Assert.notNull(clazz, "Class must not be null"); return (clazz.isPrimitive() && clazz != void.class ? primitiveTypeToWrapperMap.get(clazz) : clazz); }
/** * Determine the name of the package of the given fully-qualified class name, * e.g. "java.lang" for the {@code java.lang.String} class name. * @param fqClassName the fully-qualified class name * @return the package name, or the empty String if the class * is defined in the default package */ public static String getPackageName(String fqClassName) { Assert.notNull(fqClassName, "Class name must not be null"); int lastDotIndex = fqClassName.lastIndexOf(PACKAGE_SEPARATOR); return (lastDotIndex != -1 ? fqClassName.substring(0, lastDotIndex) : ""); }
@Override public void write(byte[] array, int offset, int length) throws IOException { Assert.notNull(array, "The data must be not null"); byte[] tmpArr = new byte[length]; System.arraycopy(array, offset, tmpArr, 0, length); write(ByteBuffer.wrap(tmpArr)); }
/** * Create a new {@code UrlResource} based on the given URI object. * * @param uri a URI * @throws MalformedURLException if the given URL path is not valid */ public UrlResource(URI uri) throws MalformedURLException { Assert.notNull(uri, "URI must not be null"); this.uri = uri; this.url = uri.toURL(); this.cleanedUrl = getCleanedUrl(this.url, uri.toString()); }
@Override public void write(byte[] array, int offset, int length) throws IOException { Assert.notNull(array, "The data must be not null"); byte[] tmpArr = new byte[length]; System.arraycopy(array, offset, tmpArr, 0, length); write(ByteBuffer.wrap(tmpArr)); }
/** * Return all interfaces that the given instance implements as Set, * including ones implemented by superclasses. * * @param instance the instance to analyze for interfaces * @return all interfaces that the given instance implements as Set */ public static Set<Class<?>> getAllInterfacesAsSet(Object instance) { Assert.notNull(instance, "Instance must not be null"); return getAllInterfacesForClassAsSet(instance.getClass()); }
/** * Determine the name of the package of the given class, * e.g. "java.lang" for the {@code java.lang.String} class. * @param clazz the class * @return the package name, or the empty String if the class * is defined in the default package */ public static String getPackageName(Class<?> clazz) { Assert.notNull(clazz, "Class must not be null"); return getPackageName(clazz.getName()); }
/** * Determine the name of the package of the given class, * e.g. "java.lang" for the {@code java.lang.String} class. * * @param clazz the class * @return the package name, or the empty String if the class * is defined in the default package */ public static String getPackageName(Class<?> clazz) { Assert.notNull(clazz, "Class must not be null"); return getPackageName(clazz.getName()); }
public <K, V> Map<K, V> queryForBeanMap(String sql, Class<V> t, BeanProcessor beanProcessor, Object... params) { String columnName = defaultBeanProcessor.getIdColumnName(t); Assert.notNull(columnName); try (Connection connection = dataSource.getConnection()) { Map<K, V> ret = this.queryForBeanMap(connection, sql, t, columnName, beanProcessor, params); connection.commit(); return ret; } catch (SQLException e) { log.error("query exception, sql: {}", e, sql); throw new DBException(e); } }
public <K, V> Map<K, V> queryForBeanMap(Connection connection, String sql, Class<V> t, Object... params) { String columnName = defaultBeanProcessor.getIdColumnName(t); Assert.notNull(columnName); return this.queryForBeanMap(connection, sql, t, columnName, defaultBeanProcessor, params); }
public int deleteById(Connection connection, Class<?> t, Object id) { SQLMapper sqlMapper = defaultBeanProcessor.generateDeleteSQL(t); Assert.notNull(sqlMapper, "sql mapper must not be null"); return this.update(connection, sqlMapper.sql, id); }
@Override public void onRequest(Listener listener) { Assert.notNull(listener, "The context listener must be not null"); session.setListener(new ReceivedRequestSessionListener(listener)); }
public <T> T queryById(Connection connection, Class<T> t, Object id) { SQLMapper sqlMapper = defaultBeanProcessor.generateQuerySQL(t); Assert.notNull(sqlMapper, "sql mapper must not be null"); return this.queryForObject(connection, sqlMapper.sql, t, id); }
@Override protected void init() { Assert.notNull(client); Assert.hasText(keyPrefix); Assert.hasText(sessionKey); map = client.getMapCache(keyPrefix + ":" + sessionKey, new FstCodec()); }