示例#1
0
 /**
  * {@inheritDoc}
  * In addition, the value gets type checked.
  * @throws \blaze\lang\IllegalArgumentException If the offset is not a number.
  * @throws \blaze\lang\IndexOutOfBoundsException If the offset is not within the range of the array.
  * @throws \blaze\lang\ClassCastException When the type of the value does not fit.
  */
 public function offsetSet($offset, $value)
 {
     if (!\blaze\lang\Integer::isNativeType($offset)) {
         throw new \blaze\lang\IllegalArgumentException('The index must be a number');
     }
     if ($offset < 0 || $offset > $this->size) {
         throw new \blaze\lang\IndexOutOfBoundsException($offset);
     }
     if (!$this->typeChecker->isType($value)) {
         throw new \blaze\lang\ClassCastException('This array may only contain objects of the given type ' . $this->typeChecker->getType());
     }
     $this->objects[$offset] = $value;
 }
示例#2
0
 private function check($value)
 {
     if (!$this->typeChecker->isType($value)) {
         throw new \blaze\lang\IllegalArgumentException('This bag may only contain objects of the given type ' . $this->typeChecker->getType());
     }
 }
示例#3
0
 private function checkValue($value)
 {
     if (!$this->typeCheckerValue->isType($value)) {
         throw new \blaze\lang\IllegalArgumentException('This sorted map may only contain values of the given type ' . $this->typeCheckerValue->getType());
     }
 }
示例#4
0
 /**
  * Returns a typed SortedBidiMap and cuts of the elements which are to much
  * @param string|blaze\lang\String|blaze\lang\ClassWrapper $type
  * @return blaze\collection\bidimap\SortedBidiMap
  */
 public static function typedSortedBidiMap(\blaze\collections\bidimap\SortedBidiMap $obj, $keyType, $valueType)
 {
     return new bidimap\TypedSortedBidiMap($obj, TypeChecker::getInstance($keyType), TypeChecker::getInstance($valueType));
 }