com.vividsolutions.jts.util.Assert类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中com.vividsolutions.jts.util.Assert类的一些代码示例,展示了Assert类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert类的具体详情如下:
包路径:com.vividsolutions.jts.util.Assert
类名称:Assert

Assert介绍

[英]A utility for making programming assertions.
[中]用于生成编程断言的实用程序。

代码示例

代码示例来源:origin: com.vividsolutions/jts

/**
 *  Always throws an <code>AssertionFailedException</code>.
 *
 *@throws  AssertionFailedException  thrown always
 */
public static void shouldNeverReachHere() {
 shouldNeverReachHere(null);
}

代码示例来源:origin: com.vividsolutions/jts

/**
 *  Throws an <code>AssertionFailedException</code> if the given objects are
 *  not equal, according to the <code>equals</code> method.
 *
 *@param  expectedValue              the correct value
 *@param  actualValue                the value being checked
 *@throws  AssertionFailedException  if the two objects are not equal
 */
public static void equals(Object expectedValue, Object actualValue) {
 equals(expectedValue, actualValue, null);
}

代码示例来源:origin: com.vividsolutions/jts

public Interval(double min, double max) {
 Assert.isTrue(min <= max);
 this.min = min;
 this.max = max;
}

代码示例来源:origin: com.vividsolutions/jts

throw new TopologyException("side location conflict", e.getCoordinate());
if (leftLoc == Location.NONE) {
 Assert.shouldNeverReachHere("found single null side (at " + e.getCoordinate() + ")");
Assert.isTrue(label.getLocation(geomIndex, Position.LEFT) == Location.NONE, "found single null side");
label.setLocation(geomIndex, Position.RIGHT, currLoc);
label.setLocation(geomIndex, Position.LEFT, currLoc);

代码示例来源:origin: org.locationtech.geogig/geogig-core

@Test
public void testIteratorHasErrorFirstElement_hasNext() {
  Exception except = new RuntimeException();
  Iterator it = mock(Iterator.class);
  when(it.hasNext()).thenReturn(Boolean.TRUE);
  when(it.next()).thenThrow(except);
  BackgroundingIterator<Integer> bit = new BackgroundingIterator<Integer>(it, 100);
  try {
    bit.hasNext();
  } catch (Exception e) {
    Assert.isTrue(e.getCause() == except);
    return; // done
  }
  Assert.shouldNeverReachHere();
}

代码示例来源:origin: com.vividsolutions/jts

public Object clone() {
 try {
  Coordinate coord = (Coordinate) super.clone();
  return coord; // return the clone
 } catch (CloneNotSupportedException e) {
  Assert.shouldNeverReachHere(
    "this shouldn't happen because this class is Cloneable");
  return null;
 }
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Constructs an AbstractSTRtree with the specified maximum number of child
 * nodes that a node may have
 * 
 * @param nodeCapacity the maximum number of child nodes in a node
 */
public AbstractSTRtree(int nodeCapacity) {
 Assert.isTrue(nodeCapacity > 1, "Node capacity must be greater than 1");
 this.nodeCapacity = nodeCapacity;
}

代码示例来源:origin: org.locationtech.geogig/geogig-core

@Test
public void testIteratorHasErrorFirstElement_next() {
  Exception except = new RuntimeException();
  Iterator it = mock(Iterator.class);
  when(it.hasNext()).thenReturn(Boolean.TRUE);
  when(it.next()).thenThrow(except);
  BackgroundingIterator<Integer> bit = new BackgroundingIterator<Integer>(it, 100);
  try {
    Integer i = bit.next(); // should throw
  } catch (Exception e) {
    Assert.isTrue(e.getCause() == except);
    return; // done
  }
  Assert.shouldNeverReachHere();
}

代码示例来源:origin: com.vividsolutions/jts

/**
 *@param  vertices  the vertices of a linear ring, which may or may not be
 *      flattened (i.e. vertices collinear)
 *@return           the coordinates with unnecessary (collinear) vertices
 *      removed
 */
private Coordinate[] cleanRing(Coordinate[] original) {
 Assert.equals(original[0], original[original.length - 1]);
 ArrayList cleanedRing = new ArrayList();
 Coordinate previousDistinctCoordinate = null;
 for (int i = 0; i <= original.length - 2; i++) {
  Coordinate currentCoordinate = original[i];
  Coordinate nextCoordinate = original[i+1];
  if (currentCoordinate.equals(nextCoordinate)) {
   continue;
  }
  if (previousDistinctCoordinate != null
    && isBetween(previousDistinctCoordinate, currentCoordinate, nextCoordinate)) {
   continue;
  }
  cleanedRing.add(currentCoordinate);
  previousDistinctCoordinate = currentCoordinate;
 }
 cleanedRing.add(original[original.length - 1]);
 Coordinate[] cleanedRingCoordinates = new Coordinate[cleanedRing.size()];
 return (Coordinate[]) cleanedRing.toArray(cleanedRingCoordinates);
}

代码示例来源:origin: com.vividsolutions/jts

/**
  * Clones this transformation
  * 
  * @return a copy of this transformation
  */
 public Object clone()
 {
   try {
     return super.clone();
   } catch(Exception ex) {
     Assert.shouldNeverReachHere();
   }
   return null;
 }
}

代码示例来源:origin: com.vividsolutions/jts

/**
 *  Throws an <code>AssertionFailedException</code> if the given assertion is
 *  not true.
 *
 *@param  assertion                  a condition that is supposed to be true
 *@throws  AssertionFailedException  if the condition is false
 */
public static void isTrue(boolean assertion) {
 isTrue(assertion, null);
}

代码示例来源:origin: com.vividsolutions/jts-core

/**
 *  Throws an <code>AssertionFailedException</code> if the given objects are
 *  not equal, according to the <code>equals</code> method.
 *
 *@param  expectedValue              the correct value
 *@param  actualValue                the value being checked
 *@throws  AssertionFailedException  if the two objects are not equal
 */
public static void equals(Object expectedValue, Object actualValue) {
 equals(expectedValue, actualValue, null);
}

代码示例来源:origin: com.vividsolutions/jts

private int getClassSortIndex() {
   if (sortedClasses == null)
     initSortedClasses();
   for (int i = 0; i < sortedClasses.length; i++) {
     if (sortedClasses[i].isInstance(this))
       return i;
   }
   Assert.shouldNeverReachHere("Class not supported: " + this.getClass());
   return -1;
 }

代码示例来源:origin: com.vividsolutions/jts

/**
  * Adds either an AbstractNode, or if this is a leaf node, a data object
  * (wrapped in an ItemBoundable)
  */
 public void addChildBoundable(Boundable childBoundable) {
  Assert.isTrue(bounds == null);
  childBoundables.add(childBoundable);
 }
}

代码示例来源:origin: Impetus/Kundera

Assert.equals(cqlQuery, expectedQuery);
    emf, em, pu, PersonCassandra.class, 200);
expectedQuery = "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"PERSON_NAME\" = 'ram and wwe' AND \"AGE\" = 10 LIMIT 200  ALLOW FILTERING";
Assert.equals(cqlQuery, expectedQuery);
    emf, em, pu, PersonCassandra.class, 200);
expectedQuery = "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"PERSON_NAME\" = 'Like-==' LIMIT 200  ALLOW FILTERING";
Assert.equals(cqlQuery, expectedQuery);
    emf, em, pu, PersonCassandra.class, 200);
expectedQuery = "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"PERSON_NAME\" = '==1' LIMIT 200  ALLOW FILTERING";
Assert.equals(cqlQuery, expectedQuery);
    emf, em, pu, PersonCassandra.class, 200);
expectedQuery = "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"PERSON_NAME\" = 'in= NOT IN >=set >< <>' LIMIT 200  ALLOW FILTERING";
Assert.equals(cqlQuery, expectedQuery);
    emf, em, pu, PersonCassandra.class, 200);
expectedQuery = "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"PERSON_NAME\" = 'in= between. >=set anand >< or <>' LIMIT 200  ALLOW FILTERING";
Assert.equals(cqlQuery, expectedQuery);

代码示例来源:origin: com.vividsolutions/jts

public Geometry getBoundary() {
 checkNotGeometryCollection(this);
 Assert.shouldNeverReachHere();
 return null;
}

代码示例来源:origin: com.vividsolutions/jts

protected void init(Coordinate p0, Coordinate p1)
{
 this.p0 = p0;
 this.p1 = p1;
 dx = p1.x - p0.x;
 dy = p1.y - p0.y;
 quadrant = Quadrant.quadrant(dx, dy);
 Assert.isTrue(! (dx == 0 && dy == 0), "EdgeEnd with identical endpoints found");
}

代码示例来源:origin: org.apache.atlas/atlas-repository

private void deletePropagatedClassificationExpectFail(AtlasEntity entity, AtlasClassification classification) {
  try {
    deletePropagatedClassification(entity, classification);
    fail();
  } catch (AtlasBaseException ex) {
    Assert.equals(ex.getAtlasErrorCode(), PROPAGATED_CLASSIFICATION_REMOVAL_NOT_SUPPORTED);
  }
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Writes a {@link Geometry} in GML2 format to a String.
 * 
 * @param geom
 * @return String GML2 Encoded Geometry
 */
public String write(Geometry geom) 
{
  StringWriter writer = new StringWriter();
  try {
    write(geom, writer);
  }
catch (IOException ex) {
 Assert.shouldNeverReachHere();
}
  return writer.toString();
}

代码示例来源:origin: com.vividsolutions/jts

private List createParentBoundablesFromVerticalSlices(List[] verticalSlices, int newLevel) {
 Assert.isTrue(verticalSlices.length > 0);
 List parentBoundables = new ArrayList();
 for (int i = 0; i < verticalSlices.length; i++) {
  parentBoundables.addAll(
     createParentBoundablesFromVerticalSlice(verticalSlices[i], newLevel));
 }
 return parentBoundables;
}

相关文章