Template method:
Loads the correspondent object, or creates if it has not persisted.

@return
the correspondent object, or null if the object is created.
978290
protected <L, S extends Persistable<L>>
    S _daoLoadOrCreate(
                    final Class<S> type,
                    final S object
                    )
    {
        CastorDao<L, S>  dao = getForwardingDao( type );
        S  p_object = dao._loadCorrespondent( object );
        if (p_object == null) {
            dao._create( object );
        }

        return p_object;
    }
1045964
public static ApptentiveAttachmentLoader getInstance() {
		if (instance == null) {
			synchronized (ApptentiveAttachmentLoader.class) {
				if (instance == null) {
					instance = new ApptentiveAttachmentLoader();
				}
			}
		}
		return instance;
	}
1054108
@SuppressWarnings("unchecked")
	public JSONNavi<T> object() {
		if (failure)
			return this;
		if (current == null && readonly)
			failure("Can not create Object child in readonly", null);
		if (current != null) {
			if (isObject())
				return this;
			if (isArray())
				failure("can not use Object feature on Array.", null);
			failure("Can not use current possition as Object", null);
		} else {
			current = mapper.createObject();
		}
		if (root == null)
			root = (T) current;
		else
			store();
		return this;
	}
442779
protected Object getObject(String pType) 
    /*throws XxxException*/ {
    	// Get class
    	Class cl = getType(pType);

    	// Return the new instance (requires empty public constructor)
    	try {
    	    return cl.newInstance();
    	}
    	catch (Exception e) {
    	    // throw new XxxException(e);
    	    throw new RuntimeException(e.getMessage());
    	}
    	
    	// Can't happen
    	//return null;
    }
1259580
public T get() {
    T value = object;
    if (value == null) {
      synchronized (this) {
        value = object;
        if (object == null) {
          object = value = supplier.get();
        }
      }
    }
    return value;
  }
384277
@Override
	public synchronized T get()
	{
		T val;

		synchronized(this)
		{
			if(valRef==null || (val = valRef.get())==null)
			{
				val = make();
				valRef = new WeakReference<T>(val);
			}
		}
		return val;
	}
1300284
def get_object(self, queryset=None):
        '''  '''
        return get_object_or_404(
            GuestList.objects.filter(id=self.kwargs.get('guestlist_id')))
1371196
public Object loadById(Class entity, Serializable id) throws Exception  {
		return getHibernateTemplate().load(entity, id);
	}
472164
public Object jsonObject() {

        if (json == null) {
            return null;
        }

        if (cached == null) {

            Object tmp = null;
            if (json[0] == '{') {
                tmp = new LazyJsonObject<String, Object>(json);
            } else if (json[0] == '[') {
                tmp = new LazyJsonArray<Object>(json);
            } else {
                try {
                    // NOTE: This if-else condition is for Jackson 2.5.0
                    // json variable is byte[] which is from Cursor.getBlob().
                    // And json byte array is ended with '\0'.
                    // '\0' causes parsing problem with Jackson 2.5.0 that we upgraded Feb 24, 2015.
                    // We did not observe this problem with Jackson 1.9.2 that we used before.
                    if(json.length > 0 && json[json.length - 1] == 0) {
                        tmp = Manager.getObjectMapper().readValue(json, 0, json.length - 1, Object.class);
                    }
                    else {
                        tmp = Manager.getObjectMapper().readValue(json, Object.class);
                    }
                } catch (Exception e) {
                    //cached will remain null
                    Log.w(Database.TAG, "Exception parsing json", e);
                }
            }

            cached = tmp;
        }
        return cached;
    }
266886
protected boolean _load ()
    {
        java.sql.ResultSet rs = null;
        try
        {
            // This synchronization is necessary for Oracle JDBC drivers 8.1.7, 9.0.1, 9.2.0.1
            // The documentation says synchronization is done within the driver, but they
            // must have overlooked something. Without the lock we'd get mysterious error
            // messages.            
            synchronized(getDbMeta())
            {
                getDbMetaTreeModel().setStatusBarMessage("Reading columns for table " + getSchema().getCatalog().getCatalogName() + "." + getSchema().getSchemaName() + "." + getTableName());
                rs = getDbMeta().getColumns(getSchema().getCatalog().getCatalogName(), 
                                                          getSchema().getSchemaName(),
                                                          getTableName(), "%");
                final java.util.ArrayList alNew = new java.util.ArrayList();
                while (rs.next())
                {
                    alNew.add(new DBMetaColumnNode(getDbMeta(), getDbMetaTreeModel(), DBMetaTableNode.this, rs.getString("COLUMN_NAME")));
                }
                alChildren = alNew;            
                javax.swing.SwingUtilities.invokeLater(new Runnable()
                {
                    public void run()
                    {
                        getDbMetaTreeModel().nodeStructureChanged(DBMetaTableNode.this);
                    }
                });
                rs.close();
            }
        }
        catch (java.sql.SQLException sqlEx)
        {
            this.getDbMetaTreeModel().reportSqlError("Error retrieving columns", sqlEx);
            try
            {
                if (rs != null) rs.close ();
            }
            catch (java.sql.SQLException sqlEx2)
            {
                this.getDbMetaTreeModel().reportSqlError("Error retrieving columns", sqlEx2);
            }
            return false;
        }
        return true;
    }
1239905
@Override
    public synchronized Subject getSubject () {
        if ( this.cachedSubject != null ) {
            return this.cachedSubject;
        }

        try {
            log.debug("Logging on");
            LoginContext lc;

	    Subject ps = super.getSubject();

            if ( this.configuration != null ) {
                lc = new LoginContext(this.serviceName, ps, this, this.configuration);
            }
            else if ( ps != null ) {
                lc = new LoginContext(this.serviceName, ps, this);
            } else {
                lc = new LoginContext(this.serviceName, this);
	    }
            lc.login();

            Subject s = lc.getSubject();
            if ( log.isDebugEnabled() ) {
                log.debug("Got subject: " + s.getPrincipals());
            }
            if ( log.isTraceEnabled() ) {
                log.trace("Got subject " + s);
            }

            this.cachedSubject = s;
            return this.cachedSubject;
        }
        catch ( LoginException e ) {
            log.error("Failed to create login context", e);
            this.cachedSubject = new Subject();
            return null;
        }
    }
1269346
@SuppressWarnings("unchecked")
    public T get() {
        if (HystrixRequestContext.getContextForCurrentThread() == null) {
            throw new IllegalStateException(HystrixRequestContext.class.getSimpleName() + ".initializeContext() must be called at the beginning of each request before RequestVariable functionality can be used.");
        }
        ConcurrentHashMap<HystrixRequestVariableDefault<?>, LazyInitializer<?>> variableMap = HystrixRequestContext.getContextForCurrentThread().state;

        // short-circuit the synchronized path below if we already have the value in the ConcurrentHashMap
        LazyInitializer<?> v = variableMap.get(this);
        if (v != null) {
            return (T) v.get();
        }

        /*
         * Optimistically create a LazyInitializer to put into the ConcurrentHashMap.
         * 
         * The LazyInitializer will not invoke initialValue() unless the get() method is invoked
         * so we can optimistically instantiate LazyInitializer and then discard for garbage collection
         * if the putIfAbsent fails.
         * 
         * Whichever instance of LazyInitializer succeeds will then have get() invoked which will call
         * the initialValue() method once-and-only-once.
         */
        LazyInitializer<T> l = new LazyInitializer<T>(this);
        LazyInitializer<?> existing = variableMap.putIfAbsent(this, l);
        if (existing == null) {
            /*
             * We won the thread-race so can use 'l' that we just created.
             */
            return l.get();
        } else {
            /*
             * We lost the thread-race so let 'l' be garbage collected and instead return 'existing'
             */
            return (T) existing.get();
        }
    }
585016
public T borrowObject() {
		T object;
		if ((object = pool.poll()) == null) {
			object = createObject();
		}

		return object;
	}
743783
private Object instanceNotYetLoaded(
		final Tuple resultset,
		final int i,
		final Loadable persister,
		final String rowIdAlias,
		final org.hibernate.engine.spi.EntityKey key,
		final LockMode lockMode,
		final org.hibernate.engine.spi.EntityKey optionalObjectKey,
		final Object optionalObject,
		final List hydratedObjects,
		final SharedSessionContractImplementor session)
	throws HibernateException {
		final String instanceClass = getInstanceClass(
				resultset,
				i,
				persister,
				key.getIdentifier(),
				session
			);

		final Object object;
		if ( optionalObjectKey != null && key.equals( optionalObjectKey ) ) {
			//its the given optional object
			object = optionalObject;
		}
		else {
			// instantiate a new instance
			object = session.instantiate( instanceClass, key.getIdentifier() );
		}

		//need to hydrate it.

		// grab its state from the ResultSet and keep it in the Session
		// (but don't yet initialize the object itself)
		// note that we acquire LockMode.READ even if it was not requested
		LockMode acquiredLockMode = lockMode == LockMode.NONE ? LockMode.READ : lockMode;
		loadFromResultSet(
				resultset,
				i,
				object,
				instanceClass,
				key,
				rowIdAlias,
				acquiredLockMode,
				persister,
				session
			);

		//materialize associations (and initialize the object) later
		hydratedObjects.add( object );

		return object;
	}
938032
public Object getObjectInstance(Object object, Name name, Context context, Hashtable<?, ?> table) throws Exception {

		Reference ref = (Reference) object;
		Enumeration<RefAddr> addrs = ref.getAll();
		Properties props = new Properties();
		while (addrs.hasMoreElements()) {
			RefAddr addr = addrs.nextElement();
			if (addr.getType().equals("driverClassName")){
				Class.forName((String) addr.getContent());
			} else {
				props.put(addr.getType(), addr.getContent());
			}
		}		
		BoneCPConfig config = new BoneCPConfig(props);

		return new BoneCPDataSource(config);
	}
350893
public Method loadMethod(){
		methodToGenerate = new Method();
		
		// the method will be created in the mapper
		membership = Membership.MAPPER;
		// class to which it belongs
		methodToGenerate.setClazz(configClass);
		
		Class<?> destinationClass = destinationField.getType();
		Class<?> sourceClass = sourceField.getType();
		
		// Return Type definition
		methodToGenerate.setReturnType(destinationClass);
		
		// Parameters type definition
		switch (methodDefined.getParameterNumber()) {
			case ZERO:methodToGenerate.setParameters(new Class<?>[]{});				    			break;
			case ONE: methodToGenerate.setParameters(new Class<?>[]{sourceClass});				    break;
			case TWO: methodToGenerate.setParameters(new Class<?>[]{destinationClass,sourceClass}); break;
		}
		
		// setting of conversion method name
		methodToGenerate.setOriginalName(methodDefined.getName());
		
		// Method name definition
		switch (methodDefined.getType()) {
			case STATIC:  methodToGenerate.setName(definedName());break;
			case DYNAMIC: methodToGenerate.setName(dynamicName());break;
		}
		
		// adds the generated name in the defined method
		methodDefined.setName(methodToGenerate.getName());
		
		int count = 1;
		String body = "{try{";
		// Parameters type definition
		switch (methodDefined.getParameterNumber()) {
			case TWO: String dType = placeholders.get(destinationTypePattern);
				  	  String dName = placeholders.get(destinationPattern);
				  	  body += dType+" "+dName+" = ("+dType+") $"+count+++";"+newLine;
			case ONE: String sType = placeholders.get(sourceTypePattern);
		  	  		  String sName = placeholders.get(sourcePattern);
		  	  		  body += sType+" "+sName+" = ("+sType+") $"+count+";"+newLine;
			default: break;
		}
		
		// Method body definition
		body += methodDefined.getContent();
		for (Entry<String, String> pair : placeholders.entrySet())
			// only if the placeholder is used
			if(!isNull(pair.getValue()))
				body = body.replaceAll(pair.getKey(),  Matcher.quoteReplacement(pair.getValue()));
		return methodToGenerate.setBody(body+"}catch(java.lang.Exception e){"+error()+"}return "+defaultPrimitiveValue(destinationClass)+";}");
	}
792645
public Object getAsObject() {
		List<Object> result = new ArrayList<Object>();
		for (Object element : this)
			result.add(element);
		return result;
	}

	/**
	 * Sets a new value for this array element
	 * 
	 * @param value the new object value.
	 */
	public void setAsObject(Object value) {
		clear();
		List<Object> elements = ArrayConverter.toArray(value);
		append(elements);
	}

	/**
	 * Appends new elements to this array.
	 * 
	 * @param elements a list of elements to be added.
	 */
	public void append(Iterable<?> elements) {
		if (elements != null) {
			for (Object item : elements)
				add(item);
		}
	}

	/**
	 * Appends new elements to this array.
	 * 
	 * @param elements a list of elements to be added.
	 */
	public void append(Object[] elements) {
		if (elements != null) {
			for (Object item : elements)
				add(item);
		}
	}

	/**
	 * Gets an array element specified by its index.
	 * 
	 * @param index an index of the element to get.
	 * @return the value of the array element.
	 */
	public Object getAsObject(int index) {
		return get(index);
	}

	/**
	 * Sets a new value into array element specified by its index.
	 * 
	 * @param index an index of the element to put.
	 * @param value a new value for array element.
	 */
	public void setAsObject(int index, Object value) {
		set(index, value);
	}

//    @Override
//    public void add(Object value) {
//    	add(new AnyValue(value));
//    }

	/**
	 * Converts array element into a string or returns null if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return string value of the element or null if conversion is not supported.
	 * 
	 * @see StringConverter#toNullableString(Object)
	 */
	public String getAsNullableString(int index) {
		Object value = getAsObject(index);
		return StringConverter.toNullableString(value);
	}

	/**
	 * Converts array element into a string or returns "" if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return string value ot the element or "" if conversion is not supported.
	 * 
	 * @see #getAsStringWithDefault(int, String)
	 */
	public String getAsString(int index) {
		return getAsStringWithDefault(index, null);
	}

	/**
	 * Converts array element into a string or returns default value if conversion
	 * is not possible.
	 * 
	 * @param index        an index of element to get.
	 * @param defaultValue the default value
	 * @return string value ot the element or default value if conversion is not
	 *         supported.
	 * 
	 * @see StringConverter#toStringWithDefault(Object, String)
	 */
	public String getAsStringWithDefault(int index, String defaultValue) {
		Object value = getAsObject(index);
		return StringConverter.toStringWithDefault(value, defaultValue);
	}

	/**
	 * Converts array element into a boolean or returns null if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return boolean value of the element or null if conversion is not supported.
	 * 
	 * @see BooleanConverter#toNullableBoolean(Object)
	 */
	public Boolean getAsNullableBoolean(int index) {
		Object value = getAsObject(index);
		return BooleanConverter.toNullableBoolean(value);
	}

	/**
	 * Converts array element into a boolean or returns false if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return boolean value ot the element or false if conversion is not supported.
	 * 
	 * @see #getAsBooleanWithDefault(int, boolean)
	 */
	public Boolean getAsBoolean(int index) {
		return getAsBooleanWithDefault(index, false);
	}

	/**
	 * Converts array element into a boolean or returns default value if conversion
	 * is not possible.
	 * 
	 * @param index        an index of element to get.
	 * @param defaultValue the default value
	 * @return boolean value ot the element or default value if conversion is not
	 *         supported.
	 * 
	 * @see BooleanConverter#toBooleanWithDefault(Object, boolean)
	 */
	public boolean getAsBooleanWithDefault(int index, boolean defaultValue) {
		Object value = getAsObject(index);
		return BooleanConverter.toBooleanWithDefault(value, defaultValue);
	}

	/**
	 * Converts array element into an integer or returns null if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return integer value of the element or null if conversion is not supported.
	 * 
	 * @see IntegerConverter#toNullableInteger(Object)
	 */
	public Integer getAsNullableInteger(int index) {
		Object value = getAsObject(index);
		return IntegerConverter.toNullableInteger(value);
	}

	/**
	 * Converts array element into an integer or returns 0 if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return integer value ot the element or 0 if conversion is not supported.
	 * 
	 * @see #getAsIntegerWithDefault(int, int)
	 */
	public int getAsInteger(int index) {
		return getAsIntegerWithDefault(index, 0);
	}

	/**
	 * Converts array element into an integer or returns default value if conversion
	 * is not possible.
	 * 
	 * @param index        an index of element to get.
	 * @param defaultValue the default value
	 * @return integer value ot the element or default value if conversion is not
	 *         supported.
	 * 
	 * @see IntegerConverter#toIntegerWithDefault(Object, int)
	 */
	public int getAsIntegerWithDefault(int index, int defaultValue) {
		Object value = getAsObject(index);
		return IntegerConverter.toIntegerWithDefault(value, defaultValue);
	}

	/**
	 * Converts array element into a long or returns null if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return long value of the element or null if conversion is not supported.
	 * 
	 * @see LongConverter#toNullableLong(Object)
	 */
	public Long getAsNullableLong(int index) {
		Object value = getAsObject(index);
		return LongConverter.toNullableLong(value);
	}

	/**
	 * Converts array element into a long or returns 0 if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return long value ot the element or 0 if conversion is not supported.
	 * 
	 * @see #getAsLongWithDefault(int, long)
	 */
	public long getAsLong(int index) {
		return getAsLongWithDefault(index, 0);
	}

	/**
	 * Converts array element into a long or returns default value if conversion is
	 * not possible.
	 * 
	 * @param index        an index of element to get.
	 * @param defaultValue the default value
	 * @return long value ot the element or default value if conversion is not
	 *         supported.
	 * 
	 * @see LongConverter#toLongWithDefault(Object, long)
	 */
	public long getAsLongWithDefault(int index, long defaultValue) {
		Object value = getAsObject(index);
		return LongConverter.toLongWithDefault(value, defaultValue);
	}

	/**
	 * Converts array element into a float or returns null if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return float value of the element or null if conversion is not supported.
	 * 
	 * @see FloatConverter#toNullableFloat(Object)
	 */
	public Float getAsNullableFloat(int index) {
		Object value = getAsObject(index);
		return FloatConverter.toNullableFloat(value);
	}

	/**
	 * Converts array element into a float or returns 0 if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return float value ot the element or 0 if conversion is not supported.
	 * 
	 * @see #getAsFloatWithDefault(int, float)
	 */
	public float getAsFloat(int index) {
		return getAsFloatWithDefault(index, 0);
	}

	/**
	 * Converts array element into a float or returns default value if conversion is
	 * not possible.
	 * 
	 * @param index        an index of element to get.
	 * @param defaultValue the default value
	 * @return float value ot the element or default value if conversion is not
	 *         supported.
	 * 
	 * @see FloatConverter#toFloatWithDefault(Object, float)
	 */
	public float getAsFloatWithDefault(int index, float defaultValue) {
		Object value = getAsObject(index);
		return FloatConverter.toFloatWithDefault(value, defaultValue);
	}

	/**
	 * Converts array element into a double or returns null if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return double value of the element or null if conversion is not supported.
	 * 
	 * @see DoubleConverter#toNullableDouble(Object)
	 */
	public Double getAsNullableDouble(int index) {
		Object value = getAsObject(index);
		return DoubleConverter.toNullableDouble(value);
	}

	/**
	 * Converts array element into a double or returns 0 if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return double value ot the element or 0 if conversion is not supported.
	 * 
	 * @see #getAsDoubleWithDefault(int, double)
	 */
	public double getAsDouble(int index) {
		return getAsDoubleWithDefault(index, 0);
	}

	/**
	 * Converts array element into a double or returns default value if conversion
	 * is not possible.
	 * 
	 * @param index        an index of element to get.
	 * @param defaultValue the default value
	 * @return double value ot the element or default value if conversion is not
	 *         supported.
	 * 
	 * @see DoubleConverter#toDoubleWithDefault(Object, double)
	 */
	public double getAsDoubleWithDefault(int index, double defaultValue) {
		Object value = getAsObject(index);
		return DoubleConverter.toDoubleWithDefault(value, defaultValue);
	}

	/**
	 * Converts array element into a Date or returns null if conversion is not
	 * possible.
	 * 
	 * @param index an index of element to get.
	 * @return ZonedDateTime value of the element or null if conversion is not supported.
	 * 
	 * @see DateTimeConverter#toNullableDateTime(Object)
	 */
	public ZonedDateTime getAsNullableDateTime(int index) {
		Object value = getAsObject(index);
		return DateTimeConverter.toNullableDateTime(value);
	}

	/**
	 * Converts array element into a Date or returns the current date if conversion
	 * is not possible.
	 * 
	 * @param index an index of element to get.
	 * @return ZonedDateTime value ot the element or the current date if conversion is not
	 *         supported.
	 * 
	 * @see #getAsDateTimeWithDefault(int, ZonedDateTime)
	 */
	public ZonedDateTime getAsDateTime(int index) {
		return getAsDateTimeWithDefault(index, null);
	}

	/**
	 * Converts array element into a Date or returns default value if conversion is
	 * not possible.
	 * 
	 * @param index        an index of element to get.
	 * @param defaultValue the default value
	 * @return ZonedDateTime value ot the element or default value if conversion is not
	 *         supported.
	 * 
	 * @see DateTimeConverter#toDateTimeWithDefault(Object, ZonedDateTime)
	 */
	public ZonedDateTime getAsDateTimeWithDefault(int index, ZonedDateTime defaultValue) {
		Object value = getAsObject(index);
		return DateTimeConverter.toDateTimeWithDefault(value, defaultValue);
	}

	public Duration getAsNullableDuration(int index) {
		Object value = getAsObject(index);
		return DurationConverter.toNullableDuration(value);
	}

	public Duration getAsDuration(int index) {
		return getAsDurationWithDefault(index, null);
	}

	public Duration getAsDurationWithDefault(int index, Duration defaultValue) {
		Object value = getAsObject(index);
		return DurationConverter.toDurationWithDefault(value, defaultValue);
	}

	public <T extends Enum<T>> T getAsNullableEnum(Class<T> type, int index) {
		Object value = getAsObject(index);
		return EnumConverter.toNullableEnum(type, value);
	}

	public <T extends Enum<T>> T getAsEnum(Class<T> type, int index) {
		return getAsEnumWithDefault(type, index, null);
	}

	public <T extends Enum<T>> T getAsEnumWithDefault(Class<T> type, int index, T defaultValue) {
		Object value = getAsObject(index);
		return EnumConverter.toEnumWithDefault(type, value, defaultValue);
	}

	/**
	 * Converts array element into a value defined by specied typecode. If
	 * conversion is not possible it returns null.
	 * 
	 * @param type  the Class type that defined the type of the result
	 * @param index an index of element to get.
	 * @return element value defined by the typecode or null if conversion is not
	 *         supported.
	 * 
	 * @see TypeConverter#toNullableType(Class, Object)
	 */
	public <T> T getAsNullableType(Class<T> type, int index) {
		Object value = getAsObject(index);
		return TypeConverter.toNullableType(type, value);
	}

	/**
	 * Converts array element into a value defined by specied typecode. If
	 * conversion is not possible it returns default value for the specified type.
	 * 
	 * @param type  the Class type that defined the type of the result
	 * @param index an index of element to get.
	 * @return element value defined by the typecode or default if conversion is not
	 *         supported.
	 * 
	 * @see #getAsTypeWithDefault(Class, int, Object)
	 */
	public <T> T getAsType(Class<T> type, int index) {
		return getAsTypeWithDefault(type, index, null);
	}

	/**
	 * Converts array element into a value defined by specied typecode. If
	 * conversion is not possible it returns default value.
	 * 
	 * @param type         the Class type that defined the type of the result
	 * @param index        an index of element to get.
	 * @param defaultValue the default value
	 * @return element value defined by the typecode or default value if conversion
	 *         is not supported.
	 * 
	 * @see TypeConverter#toTypeWithDefault(Class, Object, Object)
	 */
	public <T> T getAsTypeWithDefault(Class<T> type, int index, T defaultValue) {
		Object value = getAsObject(index);
		return TypeConverter.toTypeWithDefault(type, value, defaultValue);
	}

	/**
	 * Converts array element into an AnyValue or returns an empty AnyValue if
	 * conversion is not possible.
	 * 
	 * @param index an index of element to get.
	 * @return AnyValue value of the element or empty AnyValue if conversion is not
	 *         supported.
	 * 
	 * @see AnyValue
	 * @see AnyValue#AnyValue(Object)
	 */
	public AnyValue getAsValue(int index) {
		Object value = getAsObject(index);
		return new AnyValue(value);
	}

	/**
	 * Converts array element into an AnyValueArray or returns null if conversion is
	 * not possible.
	 * 
	 * @param index an index of element to get.
	 * @return AnyValueArray value of the element or null if conversion is not
	 *         supported.
	 * 
	 * @see #fromValue(Object)
	 */
	public AnyValueArray getAsNullableArray(int index) {
		Object value = getAsObject(index);
		return value != null ? AnyValueArray.fromValue(value) : null;
	}

	/**
	 * Converts array element into an AnyValueArray or returns empty AnyValueArray
	 * if conversion is not possible.
	 * 
	 * @param index an index of element to get.
	 * @return AnyValueArray value of the element or empty AnyValueArray if
	 *         conversion is not supported.
	 * 
	 * @see #fromValue(Object)
	 */
	public AnyValueArray getAsArray(int index) {
		Object value = getAsObject(index);
		return AnyValueArray.fromValue(value);
	}

	/**
	 * Converts array element into an AnyValueArray or returns default value if
	 * conversion is not possible.
	 * 
	 * @param index        an index of element to get.
	 * @param defaultValue the default value
	 * @return AnyValueArray value of the element or default value if conversion is
	 *         not supported.
	 * 
	 * @see #getAsNullableArray(int)
	 */
	public AnyValueArray getAsArrayWithDefault(int index, AnyValueArray defaultValue) {
		AnyValueArray result = getAsNullableArray(index);
		return result != null ? result : defaultValue;
	}

	/**
	 * Converts array element into an AnyValueMap or returns null if conversion is
	 * not possible.
	 * 
	 * @param index an index of element to get.
	 * @return AnyValueMap value of the element or null if conversion is not
	 *         supported.
	 * 
	 * @see AnyValueMap
	 * @see AnyValueMap#fromValue(Object)
	 */
	public AnyValueMap getAsNullableMap(int index) {
		Object value = getAsObject(index);
		return value != null ? AnyValueMap.fromValue(value) : null;
	}

	/**
	 * Converts array element into an AnyValueMap or returns empty AnyValueMap if
	 * conversion is not possible.
	 * 
	 * @param index an index of element to get.
	 * @return AnyValueMap value of the element or empty AnyValueMap if conversion
	 *         is not supported.
	 * 
	 * @see AnyValueMap
	 * @see AnyValueMap#fromValue(Object)
	 */
	public AnyValueMap getAsMap(int index) {
		Object value = getAsObject(index);
		return AnyValueMap.fromValue(value);
	}

	/**
	 * Converts array element into an AnyValueMap or returns default value if
	 * conversion is not possible.
	 * 
	 * @param index        an index of element to get.
	 * @param defaultValue the default value
	 * @return AnyValueMap value of the element or default value if conversion is
	 *         not supported.
	 * 
	 * @see #getAsNullableMap(int)
	 */
	public AnyValueMap getAsMapWithDefault(int index, AnyValueMap defaultValue) {
		AnyValueMap result = getAsNullableMap(index);
		return result != null ? AnyValueMap.fromValue(result) : defaultValue;
	}

	/**
	 * Checks if this array contains a value. The check uses direct comparison
	 * between elements and the specified value.
	 * 
	 * @param value a value to be checked
	 * @return true if this array contains the value or false otherwise.
	 */
	public boolean contains(Object value) {
		for (Object element : this) {
			if (value == null && element == null)
				return true;
			if (value == null || element == null)
				continue;
			if (value.equals(element))
				return true;
		}

		return false;
	}

	/**
	 * Checks if this array contains a value. The check before comparison converts
	 * elements and the value to type specified by type code.
	 * 
	 * @param type  a Class type that defines a type to convert values before
	 *              comparison
	 * @param value a value to be checked
	 * @return true if this array contains the value or false otherwise.
	 * 
	 * @see TypeConverter#toType(Class, Object)
	 * @see TypeConverter#toNullableType(Class, Object)
	 */
	public <T> boolean containsAsType(Class<T> type, Object value) {
		T typedValue = TypeConverter.toType(type, value);

		for (Object thisValue : this) {
			T thisTypedValue = TypeConverter.toNullableType(type, thisValue);

			if (typedValue == null && thisTypedValue == null)
				return true;
			if (typedValue == null || thisTypedValue == null)
				continue;
			if (typedValue.equals(thisTypedValue))
				return true;
		}

		return false;
	}

	/**
	 * Creates a binary clone of this object.
	 * 
	 * @return a clone of this object.
	 */
	public Object clone() {
		return new AnyValueArray(this);
	}

	/**
	 * Gets a string representation of the object. The result is a comma-separated
	 * list of string representations of individual elements as
	 * "value1,value2,value3"
	 * 
	 * @return a string representation of the object.
	 *
	 * @see StringConverter#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		for (int index = 0; index < size(); index++) {
			if (index > 0)
				builder.append(',');
			builder.append(getAsStringWithDefault(index, ""));
		}
		return builder.toString();
	}

	/**
	 * Creates a new AnyValueArray from a list of values
	 * 
	 * @param values a list of values to initialize the created AnyValueArray
	 * @return a newly created AnyValueArray.
	 */
	public static AnyValueArray fromValues(Object... values) {
		return new AnyValueArray(values);
	}

	/**
	 * Converts specified value into AnyValueArray.
	 * 
	 * @param value value to be converted
	 * @return a newly created AnyValueArray.
	 * 
	 * @see ArrayConverter#toNullableArray(Object)
	 */
	public static AnyValueArray fromValue(Object value) {
		List<Object> values = ArrayConverter.toNullableArray(value);
		return new AnyValueArray(values);
	}

	/**
	 * Splits specified string into elements using a separator and assigns the
	 * elements to a newly created AnyValueArray.
	 * 
	 * @param values           a string value to be split and assigned to
	 *                         AnyValueArray
	 * @param separator        a separator to split the string
	 * @param removeDuplicates (optional) true to remove duplicated elements
	 * @return a newly created AnyValueArray.
	 */
	public static AnyValueArray fromString(String values, String separator, boolean removeDuplicates) {
		AnyValueArray result = new AnyValueArray();

		if (values == null || values.length() == 0)
			return result;

		String[] items = values.split(separator, -1);
		for (String item : items) {
			if ((item != null && item.length() > 0) || removeDuplicates == false)
				result.add(item != null ? new AnyValue(item) : null);
		}

		return result;
	}

	/**
	 * Splits specified string into elements using a separator and assigns the
	 * elements to a newly created AnyValueArray.
	 * 
	 * @param values    a string value to be split and assigned to AnyValueArray
	 * @param separator a separator to split the string
	 * @return a newly created AnyValueArray.
	 */
	public static AnyValueArray fromString(String values, String separator) {
		return AnyValueArray.fromString(values, separator, false);
	}
}