/** * Instantiates a new MultiPoint. * * @param firstPoint the first point * @param additionalPoints the additional points */ public GeoMultiPoint(GeoPoint firstPoint, GeoPoint... additionalPoints) { super( TYPE ); Contracts.assertNotNull( firstPoint, "firstPoint" ); Contracts.assertNotNull( additionalPoints, "additionalPoints" ); this.points = new ArrayList<>( Arrays.asList( ArrayHelper.concat( firstPoint, additionalPoints ) ) ); }
/** * A regular embedded is an element that it is embedded but it is not a key or a collection. * * @param keyColumnNames the column names representing the identifier of the entity * @param column the column we want to check * @return {@code true} if the column represent an attribute of a regular embedded element, {@code false} otherwise */ public static boolean isPartOfRegularEmbedded(String[] keyColumnNames, String column) { return isPartOfEmbedded( column ) && !ArrayHelper.contains( keyColumnNames, column ); }
/** * Check if an array contains an element. * * @param array the array with all the elements * @param element the element to find in the array * @return {@code true} if the array contains the element */ public static boolean contains(Object[] array, Object element) { return indexOf( array, element ) != -1; }
subclassTables.add( jdbcEnvironment.getQualifiedObjectNameFormatter().format( table.getQualifiedTableName(), dialect ) ); subclassSpaces = ArrayHelper.toStringArray( subclassTables ); constraintOrderedTableNames = ArrayHelper.toStringArray( tableNames ); constraintOrderedKeyColumnNames = ArrayHelper.to2DStringArray( keyColumns );
@Test public void testSlice() { String[] strings = new String[]{ "1", "2", "3" }; int begin = 0; int length = 2; String[] expResult = new String[]{ "1", "2" }; String[] result = ArrayHelper.slice( strings, begin, length ); assertArrayEquals( expResult, result ); }
@Test public void testTo2DStringArray() { List<String[]> keyColumns = new ArrayList<>(); keyColumns.add( new String[]{ "col1", "col2" } ); keyColumns.add( new String[]{ "col3", "col4", "col5" } ); keyColumns.add( new String[]{ "col1" } ); String[][] expectedArr = new String[3][]; expectedArr[0] = keyColumns.get( 0 ); expectedArr[1] = keyColumns.get( 1 ); expectedArr[2] = keyColumns.get( 2 ); String[][] resultArr = ArrayHelper.to2DStringArray( keyColumns ); assertThat( resultArr ).isEqualTo( expectedArr ); }
@Test public void testToStringArray() { assertArrayEquals( new String[]{ "1", "2" }, ArrayHelper.toStringArray( Arrays.asList( new String[]{ "1", "2" } ) ) ); }
@Override public Object hydrate(Tuple rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException { int begin = 0; boolean notNull = false; Object[] values = new Object[propertySpan]; for ( int i = 0; i < propertySpan; i++ ) { int length = propertyTypes[i].getColumnSpan( session.getFactory() ); String[] range = ArrayHelper.slice( names, begin, length ); //cache this Object val = propertyTypes[i].hydrate( rs, range, session, owner ); if ( val == null ) { if ( componentType.isKey() ) { return null; //different nullability rules for pk/fk } } else { notNull = true; } values[i] = val; begin += length; } return notNull ? values : null; }
/** * Instantiates a new GeometryCollection. * * @param firstGeoObject the first {@link AbstractGeoJsonObject} * @param additionalGeoObjects the additional {@link AbstractGeoJsonObject} */ public GeoCollection(AbstractGeoJsonObject firstGeoObject, AbstractGeoJsonObject... additionalGeoObjects) { super( TYPE ); Contracts.assertNotNull( firstGeoObject, "firstGeoObject" ); Contracts.assertNotNull( additionalGeoObjects, "additionalGeoObjects" ); this.geometries = new ArrayList<>( Arrays.asList( ArrayHelper.concat( firstGeoObject, additionalGeoObjects ) ) ); }
/** * Check if the property is part of the identifier of the entity. * * @param persister the {@link OgmEntityPersister} of the entity with the property * @param namesWithoutAlias the path to the property with all the aliases resolved * @return {@code true} if the property is part of the id, {@code false} otherwise. */ public boolean isIdProperty(OgmEntityPersister persister, List<String> namesWithoutAlias) { String join = StringHelper.join( namesWithoutAlias, "." ); Type propertyType = persister.getPropertyType( namesWithoutAlias.get( 0 ) ); String[] identifierColumnNames = persister.getIdentifierColumnNames(); if ( propertyType.isComponentType() ) { String[] embeddedColumnNames = persister.getPropertyColumnNames( join ); for ( String embeddedColumn : embeddedColumnNames ) { if ( !ArrayHelper.contains( identifierColumnNames, embeddedColumn ) ) { return false; } } return true; } return ArrayHelper.contains( identifierColumnNames, join ); }
@Test public void testIndexOf() { Object[] array = new Integer[]{ 1, 2, 3 }; Object element = 3; int expResult = 2; int result = ArrayHelper.indexOf( array, element ); assertEquals( expResult, result ); }
/** * Instantiates a new GeometryCollection. * * @param firstGeoObject the first {@link AbstractGeoJsonObject} * @param additionalGeoObjects the additional {@link AbstractGeoJsonObject} */ public GeoCollection(AbstractGeoJsonObject firstGeoObject, AbstractGeoJsonObject... additionalGeoObjects) { super( TYPE ); Contracts.assertNotNull( firstGeoObject, "firstGeoObject" ); Contracts.assertNotNull( additionalGeoObjects, "additionalGeoObjects" ); this.geometries = new ArrayList<>( Arrays.asList( ArrayHelper.concat( firstGeoObject, additionalGeoObjects ) ) ); }
/** * Check if the property is part of the identifier of the entity. * * @param persister the {@link OgmEntityPersister} of the entity with the property * @param namesWithoutAlias the path to the property with all the aliases resolved * @return {@code true} if the property is part of the id, {@code false} otherwise. */ public boolean isIdProperty(OgmEntityPersister persister, List<String> namesWithoutAlias) { String join = StringHelper.join( namesWithoutAlias, "." ); Type propertyType = persister.getPropertyType( namesWithoutAlias.get( 0 ) ); String[] identifierColumnNames = persister.getIdentifierColumnNames(); if ( propertyType.isComponentType() ) { String[] embeddedColumnNames = persister.getPropertyColumnNames( join ); for ( String embeddedColumn : embeddedColumnNames ) { if ( !ArrayHelper.contains( identifierColumnNames, embeddedColumn ) ) { return false; } } return true; } return ArrayHelper.contains( identifierColumnNames, join ); } }
/** * Instantiates a new MultiLineString. * * @param firstLineString the first LineString * @param additionalLineStrings the additional LineStrings */ public GeoMultiLineString(GeoLineString firstLineString, GeoLineString... additionalLineStrings) { super( TYPE ); Contracts.assertNotNull( firstLineString, "firstLineString" ); Contracts.assertNotNull( additionalLineStrings, "additionalLineStrings" ); this.lineStrings = new ArrayList<>( Arrays.asList( ArrayHelper.concat( firstLineString, additionalLineStrings ) ) ); }
@Test public void testContains() { Object[] array = new Integer[]{ 1, 2, 3 }; Object element = 3; boolean expResult = true; boolean result = ArrayHelper.contains( array, element ); assertEquals( expResult, result ); }
/** * Instantiates a new MultiPolygon. * * @param firstPolygon the first Polygon * @param additionalPolygons the additional Polygons */ public GeoMultiPolygon(GeoPolygon firstPolygon, GeoPolygon... additionalPolygons) { super( TYPE ); Contracts.assertNotNull( firstPolygon, "firstPolygon" ); Contracts.assertNotNull( additionalPolygons, "additionalPolygons" ); this.polygons = new ArrayList<>( Arrays.asList( ArrayHelper.concat( firstPolygon, additionalPolygons ) ) ); }
/** * Instantiates a new MultiPolygon. * * @param firstPolygon the first Polygon * @param additionalPolygons the additional Polygons */ public GeoMultiPolygon(GeoPolygon firstPolygon, GeoPolygon... additionalPolygons) { super( TYPE ); Contracts.assertNotNull( firstPolygon, "firstPolygon" ); Contracts.assertNotNull( additionalPolygons, "additionalPolygons" ); this.polygons = new ArrayList<>( Arrays.asList( ArrayHelper.concat( firstPolygon, additionalPolygons ) ) ); }
/** * Instantiates a new MultiLineString. * * @param firstLineString the first LineString * @param additionalLineStrings the additional LineStrings */ public GeoMultiLineString(GeoLineString firstLineString, GeoLineString... additionalLineStrings) { super( TYPE ); Contracts.assertNotNull( firstLineString, "firstLineString" ); Contracts.assertNotNull( additionalLineStrings, "additionalLineStrings" ); this.lineStrings = new ArrayList<>( Arrays.asList( ArrayHelper.concat( firstLineString, additionalLineStrings ) ) ); }
/** * Instantiates a new MultiPoint. * * @param firstPoint the first point * @param additionalPoints the additional points */ public GeoMultiPoint(GeoPoint firstPoint, GeoPoint... additionalPoints) { super( TYPE ); Contracts.assertNotNull( firstPoint, "firstPoint" ); Contracts.assertNotNull( additionalPoints, "additionalPoints" ); this.points = new ArrayList<>( Arrays.asList( ArrayHelper.concat( firstPoint, additionalPoints ) ) ); }
public Statement getUpdateEntityPropertiesStatement(Object[] columnvalues, Map<String, Object> properties) { String query = getUpdateEntityPropertiesQuery( properties ); Object[] paramsValues = ArrayHelper.concat( Arrays.asList( columnvalues, new Object[properties.size()] ) ); int index = columnvalues.length; for ( Map.Entry<String, Object> entry : properties.entrySet() ) { paramsValues[index++] = entry.getValue(); } return new Statement( query, params( paramsValues ) ); }