List of usage examples for org.apache.commons.lang NullArgumentException NullArgumentException
public NullArgumentException(String argName)
Instantiates with the given argument name.
From source file:org.monkeys.gui.PopupWindow.java
public PopupWindow(final Frame parent, final Component base) { super(parent); if (null == base) { throw new NullArgumentException("component"); }//w w w. ja v a 2s .c om this.addWindowFocusListener(new WindowAdapter() { @Override public void windowLostFocus(WindowEvent e) { hidePopup(); } }); base.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { hidePopup(); } @Override public void componentMoved(ComponentEvent e) { hidePopup(); } @Override public void componentHidden(ComponentEvent e) { hidePopup(); } }); base.addHierarchyListener(new HierarchyListener() { @Override public void hierarchyChanged(HierarchyEvent e) { hidePopup(); } }); }
From source file:org.normandra.cassandra.CassandraDatabase.java
public CassandraDatabase(final String keyspace, final Cluster cluster, final EntityCacheFactory cache, final DatabaseConstruction mode, final ExecutorService executor, final DatabaseMeta meta) { if (null == keyspace) { throw new NullArgumentException("keyspace"); }/*from www. j a v a 2 s . c o m*/ if (null == cluster) { throw new NullArgumentException("host"); } if (null == mode) { throw new NullArgumentException("mode"); } if (null == cache) { throw new NullArgumentException("cache factory"); } if (null == executor) { throw new NullArgumentException("executor"); } this.keyspaceName = keyspace; this.cluster = cluster; this.constructionMode = mode; this.cache = cache; this.executor = executor; this.meta = meta; }
From source file:org.normandra.cassandra.CassandraDatabase.java
@Override public void refresh() throws NormandraException { if (null == meta) { throw new NullArgumentException("database metadata"); }//from w w w . ja v a 2 s . c om if (DatabaseConstruction.NONE.equals(this.constructionMode)) { return; } // create all entity tables for (final String table : meta.getTables()) { try { this.refreshEntityTable(table, meta); } catch (final Exception e) { throw new NormandraException("Unable to refresh entity table [" + table + "].", e); } } // setup any table sequence/id generators for (final EntityMeta entity : meta) { for (final Class<?> entityType : entity.getTypes()) { final AnnotationParser parser = new AnnotationParser(new BasicColumnAccessorFactory(), entityType); for (final Map.Entry<Field, GeneratedValue> entry : parser.getGenerators(entityType).entrySet()) { final Field field = entry.getKey(); final GeneratedValue generator = entry.getValue(); final String type = generator.generator(); String tableName = "id_generator"; String keyColumn = "id"; String keyValue = CaseUtils.camelToSnakeCase(entity.getTable()); String valueColumn = "value"; if (GenerationType.TABLE.equals(generator.strategy())) { for (final TableGenerator table : parser.findAnnotations(entityType, TableGenerator.class)) { if (type.equalsIgnoreCase(table.name())) { if (!table.table().isEmpty()) { tableName = table.table(); } if (!table.pkColumnName().isEmpty()) { keyColumn = table.pkColumnName(); } if (!table.pkColumnValue().isEmpty()) { keyValue = table.pkColumnValue(); } if (!table.valueColumnName().isEmpty()) { valueColumn = table.valueColumnName(); } } } } else if (GenerationType.SEQUENCE.equals(generator.strategy())) { for (final SequenceGenerator sequence : parser.findAnnotations(entityType, SequenceGenerator.class)) { if (type.equalsIgnoreCase(sequence.name())) { if (!sequence.sequenceName().isEmpty()) { keyValue = sequence.sequenceName(); } } } } else if (GenerationType.IDENTITY.equals(generator.strategy())) { throw new NormandraException( "Cassandra CQL3 does not support identity primary key generation."); } try { this.refreshTableGenerator(tableName, keyColumn, valueColumn); } catch (final Exception e) { throw new NormandraException( "Unable to refresh id generator [" + generator.generator() + "].", e); } final String fieldName = field.getName(); final ColumnMeta column = entity.findColumn(fieldName); if (column != null) { final CassandraCounterIdGenerator counter = new CassandraCounterIdGenerator(tableName, keyColumn, valueColumn, keyValue, this); entity.setGenerator(column, counter); logger.info("Set counter id generator for [" + column + "] on entity [" + entity + "]."); break; } } } } }
From source file:org.normandra.cassandra.CassandraDatabaseQuery.java
CassandraDatabaseQuery(final EntityMeta context, final Statement statement, final CassandraDatabaseSession session) { if (null == statement) { throw new NullArgumentException("statement"); }//from w w w.ja va2s. c om if (null == session) { throw new NullArgumentException("session"); } this.session = session; this.entity = context; this.statement = statement; }
From source file:org.normandra.cassandra.CassandraDatabaseSession.java
public CassandraDatabaseSession(final String keyspace, final Session session, final Map<String, CassandraPreparedStatement> map, final EntityCache cache, final Executor executor) { if (null == keyspace || keyspace.isEmpty()) { throw new IllegalArgumentException("Keyspace cannot be null/empty."); }// w w w . j a va2s. co m if (null == session) { throw new NullArgumentException("session"); } if (null == cache) { throw new NullArgumentException("cache"); } if (null == executor) { throw new NullArgumentException("executor"); } this.keyspaceName = keyspace; this.session = session; this.cache = cache; this.executor = executor; this.preparedStatements = new LinkedHashMap<>(map); }
From source file:org.normandra.cassandra.CassandraDatabaseSession.java
@Override public void delete(final EntityMeta meta, final Object element) throws NormandraException { if (null == element) { throw new NullArgumentException("entity"); }/*from www . j a v a 2 s . c o m*/ if (this.isClosed()) { throw new IllegalStateException("Session is closed."); } try { final List<Delete> deletes = new ArrayList<>(); boolean hasValue = false; final Delete statement = QueryBuilder.delete().all().from(this.keyspaceName, meta.getTable()); for (final ColumnMeta column : meta.getPrimaryKeys()) { final String name = column.getName(); final ColumnAccessor accessor = meta.getAccessor(column); final Object value = accessor != null ? accessor.getValue(element, this) : null; if (value != null) { hasValue = true; statement.where(QueryBuilder.eq(name, value)); } } if (hasValue) { deletes.add(statement); } if (deletes.isEmpty()) { throw new NormandraException("No column values found - cannot delete entity."); } final RegularStatement batch; if (deletes.size() == 1) { batch = deletes.get(0); } else { final RegularStatement[] list = deletes.toArray(new RegularStatement[deletes.size()]); batch = QueryBuilder.batch(list); } final Object key = meta.getId().fromEntity(element); if (key instanceof Serializable) { this.cache.remove(meta, key); } if (this.activeUnitOfWork.get()) { this.statements.add(batch); } else { this.executeSync(batch); } } catch (final Exception e) { throw new NormandraException("Unable to delete entity [" + element + "] of type [" + meta + "].", e); } }
From source file:org.normandra.cassandra.CassandraDatabaseSession.java
@Override public void save(final EntityMeta meta, final Object element) throws NormandraException { if (this.isClosed()) { throw new IllegalStateException("Session is closed."); }/*from w w w . j a v a 2s. co m*/ if (null == meta) { throw new NullArgumentException("entity metadata"); } if (null == element) { throw new NullArgumentException("element"); } try { // generate insert/updateInstance statements final CassandraDataHandler helper = new CassandraDataHandler(this); new EntityPersistence(this).save(meta, element, helper); final List<RegularStatement> operations = helper.getOperations(); if (operations.isEmpty()) { throw new IllegalStateException( "No operations or columns identify for update - cannot save empty entity."); } final RegularStatement batch; if (operations.size() == 1) { batch = operations.get(0); } else { final RegularStatement[] list = operations.toArray(new RegularStatement[operations.size()]); batch = QueryBuilder.batch(list); } if (this.activeUnitOfWork.get()) { this.statements.add(batch); } else { this.executeSync(batch); } final Object key = meta.getId().fromEntity(element); this.cache.put(meta, key, element); } catch (final Exception e) { throw new NormandraException("Unable to save entity [" + meta + "] instance [" + element + "].", e); } }
From source file:org.normandra.cassandra.CassandraDataHandler.java
public CassandraDataHandler(final CassandraDatabaseSession session) { if (null == session) { throw new NullArgumentException("session"); }//from w w w . jav a 2 s .c o m this.session = session; }
From source file:org.normandra.meta.EntityMetaCollection.java
public EntityMetaCollection(final Iterable<EntityMeta> metas) { if (null == metas) { throw new NullArgumentException("metadata"); }//from w ww . ja v a2 s . c o m for (final EntityMeta entity : metas) { this.classMap.put(entity.getType(), entity); } }
From source file:org.normandra.neo4j.Neo4jDataFactory.java
public Neo4jDataFactory(final Graph graph, final GraphMeta meta) { if (null == graph) { throw new NullArgumentException("graph"); }/*w w w.j a v a 2 s .co m*/ if (null == meta) { throw new NullArgumentException("meta"); } this.graph = graph; this.meta = meta; }