CollectionWrapper.java

  1. /*
  2.  *    Copyright 2009-2022 the original author or authors.
  3.  *
  4.  *    Licensed under the Apache License, Version 2.0 (the "License");
  5.  *    you may not use this file except in compliance with the License.
  6.  *    You may obtain a copy of the License at
  7.  *
  8.  *       https://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  *    Unless required by applicable law or agreed to in writing, software
  11.  *    distributed under the License is distributed on an "AS IS" BASIS,
  12.  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  *    See the License for the specific language governing permissions and
  14.  *    limitations under the License.
  15.  */
  16. package org.apache.ibatis.reflection.wrapper;

  17. import java.util.Collection;
  18. import java.util.List;

  19. import org.apache.ibatis.reflection.MetaObject;
  20. import org.apache.ibatis.reflection.factory.ObjectFactory;
  21. import org.apache.ibatis.reflection.property.PropertyTokenizer;

  22. /**
  23.  * @author Clinton Begin
  24.  */
  25. public class CollectionWrapper implements ObjectWrapper {

  26.   private final Collection<Object> object;

  27.   public CollectionWrapper(MetaObject metaObject, Collection<Object> object) {
  28.     this.object = object;
  29.   }

  30.   @Override
  31.   public Object get(PropertyTokenizer prop) {
  32.     throw new UnsupportedOperationException();
  33.   }

  34.   @Override
  35.   public void set(PropertyTokenizer prop, Object value) {
  36.     throw new UnsupportedOperationException();
  37.   }

  38.   @Override
  39.   public String findProperty(String name, boolean useCamelCaseMapping) {
  40.     throw new UnsupportedOperationException();
  41.   }

  42.   @Override
  43.   public String[] getGetterNames() {
  44.     throw new UnsupportedOperationException();
  45.   }

  46.   @Override
  47.   public String[] getSetterNames() {
  48.     throw new UnsupportedOperationException();
  49.   }

  50.   @Override
  51.   public Class<?> getSetterType(String name) {
  52.     throw new UnsupportedOperationException();
  53.   }

  54.   @Override
  55.   public Class<?> getGetterType(String name) {
  56.     throw new UnsupportedOperationException();
  57.   }

  58.   @Override
  59.   public boolean hasSetter(String name) {
  60.     throw new UnsupportedOperationException();
  61.   }

  62.   @Override
  63.   public boolean hasGetter(String name) {
  64.     throw new UnsupportedOperationException();
  65.   }

  66.   @Override
  67.   public MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory) {
  68.     throw new UnsupportedOperationException();
  69.   }

  70.   @Override
  71.   public boolean isCollection() {
  72.     return true;
  73.   }

  74.   @Override
  75.   public void add(Object element) {
  76.     object.add(element);
  77.   }

  78.   @Override
  79.   public <E> void addAll(List<E> element) {
  80.     object.addAll(element);
  81.   }

  82. }