Returns the object inside Writable

@param writable
@return
@throws IllegalAccessException
@throws InstantiationException
@throws InvocationTargetException
@throws NoSuchMethodException
543064
private static Object getObjectFromWritable(Writable writable)
            throws IllegalAccessException, InstantiationException, InvocationTargetException {
        Object object = null;

        if (writable instanceof NullWritable) {
            object = NullWritable.get();
        } else if (writable instanceof BooleanWritable) {
            object = ((BooleanWritable) writable).get();
        } else if (writable instanceof Text) {
            object = writable.toString();
        } else if (writable instanceof ByteWritable) {
            object = ((ByteWritable) writable).get();
        } else if (writable instanceof IntWritable) {
            object = ((IntWritable) writable).get();
        } else if (writable instanceof LongWritable) {
            object = ((LongWritable) writable).get();
        } else if (writable instanceof BytesWritable) {
            object = ((BytesWritable) writable).getBytes();
        } else if (writable instanceof DoubleWritable) {
            object = ((DoubleWritable) writable).get();
        } else if (writable instanceof FloatWritable) {
            object = ((FloatWritable) writable).get();
        } else {
            // TODO : do nothing
        }

        return object;
    }
406388
public static byte[] toByteArray(Writable... writables) {
        final DataOutputBuffer out = new DataOutputBuffer();
        try {
            for (Writable w : writables) {
                w.write(out);
            }
            out.close();
        } catch (IOException e) {
            throw new RuntimeException("Fail to convert writables to a byte array", e);
        }
        return out.getData();
    }
265888
public static Writable newInstance(Class<? extends Writable> c,
      Configuration conf, boolean supportJobConf) {
    WritableFactory factory = WritableFactories.getFactory(c);
    if (factory != null) {
      Writable result = factory.newInstance();
      if (result instanceof Configurable) {
        ((Configurable) result).setConf(conf);
      }
      return result;
    } else {
      return ReflectionUtils.newInstance(c, conf, supportJobConf);
    }
  }
933854
public LockEntry getWriter(Object obj)
	{
		PersistenceBroker broker = getBroker();
		Identity oid = new Identity(obj, broker);
		
        LockEntry result = null;
        try
        {
        	result = getWriterRemote(oid);
        }
        catch (Throwable e)
        {
        	log.error(e);
        }
		return result;
	}
459182
@Override
    public ZuulFilter newInstance(Class clazz) throws InstantiationException, IllegalAccessException {
        return (ZuulFilter) clazz.newInstance();
    }
1076101
public function withWritable(bool $writable): self
    {
        $metadata = clone $this;
        $metadata->writable = $writable;

        return $metadata;
    }
150178
public Object get(Object object) throws IllegalAccessException, IllegalArgumentException {
        if (null != getter) {
            try {
                return getter.invoke(object);
            } catch (InvocationTargetException ite) {
                if (ite.getCause() instanceof RuntimeException && !(ite.getCause() instanceof JTransfoException)) {
                    throw (RuntimeException) ite.getCause();
                }
                throw new JTransfoException(String.format(GET_SET_ITO, getter.getName(), object.getClass().getName(),
                        getter.getDeclaringClass().getName(), ite.getCause().getMessage()), ite.getCause());
            }
        } else {
            if (!getUsingFieldLogged) {
                log.warn("Cannot find getter (not public, wrong name or wrong type), "
                                + "using field to access field {} of {}.", name, field.getType().getName());
                getUsingFieldLogged = true;
            }
            return field.get(object);
        }
    }
670714
public Writable newWritable(short writableTypeKey) {
        Constructor<? extends Writable> c = constructorMap.get(writableTypeKey);
        if (c == null) {
            throw new IllegalStateException("Unknown writable key: " + writableTypeKey);
        }
        try {
            return c.newInstance();
        } catch (Exception e) {
            throw new RuntimeException("Could not create new Writable instance");
        }
    }
1218033
@Override
    protected Iterator<?> getJavaIterator(Context cx, Scriptable scope, Object obj) {
        if (obj instanceof Wrapper) {
            Object unwrapped = ((Wrapper) obj).unwrap();
            Iterator<?> iterator = null;
            if (unwrapped instanceof Iterator)
                iterator = (Iterator<?>) unwrapped;
            if (unwrapped instanceof Iterable)
                iterator = ((Iterable<?>)unwrapped).iterator();
            return iterator;
        }
        return null;
    }
794374
protected Set<Class<? extends S>> findInstanceAbleScript(Set<Class<? extends S>> scriptClazzs)
			throws InstantiationException, IllegalAccessException {
		Set<Class<? extends S>> result=new HashSet<>();
		for (Class<? extends S> scriptClazz : scriptClazzs) 
		{
			if(isInstanceAble(scriptClazz))
			{
				result.add(scriptClazz);
			}
		}
		return result;
	}
19105
@Deprecated
	public byte [] writeObject(Object object) throws JsonProcessingException, IllegalAccessException {
		try {
			return writeDocument(new JSONAPIDocument<>(object));
		} catch (DocumentSerializationException e) {
			throw new RuntimeException(e);
		}
	}
1205982
public T get(Object source) {
		try {
			if (!method.isAccessible()) {
				method.setAccessible(true);
			}
			@SuppressWarnings("unchecked")
			T value=(T) method.invoke(source);
			return value;
		} catch (IllegalAccessException illegalAccessException) {
			return null;
		} catch (IllegalArgumentException illegalArgumentException) {
			return null;
		} catch (InvocationTargetException invocationTargetException) {
			return null;
		}
	}
158530
public static void writeObject(DataOutput out, Object instance,
                                 Class declaredClass, 
                                 Configuration conf) throws IOException {

    if (instance == null) {                       // null
      instance = new NullInstance(declaredClass, conf);
      declaredClass = Writable.class;
    }
    
    // handle FastWritable first (including ShortVoid)
    if (instance instanceof FastWritable) {
      FastWritable fwInstance = (FastWritable) instance;
      byte[] serializedName = fwInstance.getSerializedName();
      out.write(serializedName, 0, serializedName.length);
      fwInstance.write(out);
      return;
    }
    
    // write declared name
    writeStringCached(out, declaredClass.getName());

    if (declaredClass.isArray()) {                // array
      int length = Array.getLength(instance);
      out.writeInt(length);
      for (int i = 0; i < length; i++) {
        writeObject(out, Array.get(instance, i),
                    declaredClass.getComponentType(), conf);
      }
      
    } else if (declaredClass == String.class) {   // String
      UTF8.writeStringOpt(out, (String)instance);
      
    } else if (declaredClass.isPrimitive()) {     // primitive type

      if (declaredClass == Boolean.TYPE) {        // boolean
        out.writeBoolean(((Boolean)instance).booleanValue());
      } else if (declaredClass == Character.TYPE) { // char
        out.writeChar(((Character)instance).charValue());
      } else if (declaredClass == Byte.TYPE) {    // byte
        out.writeByte(((Byte)instance).byteValue());
      } else if (declaredClass == Short.TYPE) {   // short
        out.writeShort(((Short)instance).shortValue());
      } else if (declaredClass == Integer.TYPE) { // int
        out.writeInt(((Integer)instance).intValue());
      } else if (declaredClass == Long.TYPE) {    // long
        out.writeLong(((Long)instance).longValue());
      } else if (declaredClass == Float.TYPE) {   // float
        out.writeFloat(((Float)instance).floatValue());
      } else if (declaredClass == Double.TYPE) {  // double
        out.writeDouble(((Double)instance).doubleValue());
      } else if (declaredClass == Void.TYPE) {    // void
      } else {
        throw new IllegalArgumentException("Not a primitive: "+declaredClass);
      }
    } else if (declaredClass.isEnum()) {         // enum
      writeStringCached(out, ((Enum)instance).name());
    } else if (Writable.class.isAssignableFrom(declaredClass)) { // Writable
      writeStringCached(out, instance.getClass().getName());
      ((Writable)instance).write(out);

    } else {
      throw new IOException("Can't write: "+instance+" as "+declaredClass);
    }
  }
358381
public ItemWriter<Chunk<T>> getOrCreateWriter()
   {
      Node node = childNode.getOrCreate("writer");
      ItemWriter<Chunk<T>> writer = new ItemWriterImpl<Chunk<T>>(this, "writer", childNode, node);
      return writer;
   }
91954
@Override
	public MutableObjectIterator<E> getIterator() throws InterruptedException {
		synchronized (this.iteratorLock) {
			// wait while both the iterator and the exception are not set
			while (this.iterator == null && this.iteratorException == null) {
				this.iteratorLock.wait();
			}
			
			if (this.iteratorException != null) {
				throw new RuntimeException("Error obtaining the sorted input: " + this.iteratorException.getMessage(),
					this.iteratorException);
			}
			else {
				return this.iterator;
			}
		}
	}
964755
@Deprecated
	public <T> byte[] writeObjectCollection(Iterable<T> objects) throws JsonProcessingException, IllegalAccessException {
		try {
			return writeDocumentCollection(new JSONAPIDocument<>(objects));
		} catch (DocumentSerializationException e) {
			if (e.getCause() instanceof JsonProcessingException) {
				throw (JsonProcessingException) e.getCause();
			} else if (e.getCause() instanceof  IllegalAccessException) {
				throw (IllegalAccessException) e.getCause();
			}
			throw new RuntimeException(e.getCause());
		}
	}
1068488
@SuppressWarnings("rawtypes")
	public JsonWriterI getWriterByInterface(Class<?> clazz) {
		for (WriterByInterface w : writerInterfaces) {
			if (w._interface.isAssignableFrom(clazz))
				return w._writer;
		}
		return null;
	}