diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-03-10 22:40:51 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-03-14 07:59:12 +0200 |
commit | a6653d3fe49e6a97468ac09f7f2f4d621bea1078 (patch) | |
tree | 96c82e20ca6551ee4c14c8877f0258b25c63cddf /server/src/com/vaadin/data/util/MethodPropertyDescriptor.java | |
parent | f7e57d77ce621ee39167369c31d989edc5633266 (diff) | |
download | vaadin-framework-a6653d3fe49e6a97468ac09f7f2f4d621bea1078.tar.gz vaadin-framework-a6653d3fe49e6a97468ac09f7f2f4d621bea1078.zip |
Migrate vaadin-server build to maven
Change-Id: I5c740f4e9cb28103bab199f9a552153d82277e7e
Diffstat (limited to 'server/src/com/vaadin/data/util/MethodPropertyDescriptor.java')
-rw-r--r-- | server/src/com/vaadin/data/util/MethodPropertyDescriptor.java | 147 |
1 files changed, 0 insertions, 147 deletions
diff --git a/server/src/com/vaadin/data/util/MethodPropertyDescriptor.java b/server/src/com/vaadin/data/util/MethodPropertyDescriptor.java deleted file mode 100644 index f94ee75ac3..0000000000 --- a/server/src/com/vaadin/data/util/MethodPropertyDescriptor.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.data.util; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.vaadin.data.Property; -import com.vaadin.util.ReflectTools; -import com.vaadin.util.SerializerHelper; - -/** - * Property descriptor that is able to create simple {@link MethodProperty} - * instances for a bean, using given accessors. - * - * @param <BT> - * bean type - * - * @since 6.6 - */ -public class MethodPropertyDescriptor<BT> implements - VaadinPropertyDescriptor<BT> { - - private final String name; - private Class<?> propertyType; - private transient Method readMethod; - private transient Method writeMethod; - - /** - * Creates a property descriptor that can create MethodProperty instances to - * access the underlying bean property. - * - * @param name - * of the property - * @param propertyType - * type (class) of the property - * @param readMethod - * getter {@link Method} for the property - * @param writeMethod - * setter {@link Method} for the property or null if read-only - * property - */ - public MethodPropertyDescriptor(String name, Class<?> propertyType, - Method readMethod, Method writeMethod) { - this.name = name; - this.propertyType = ReflectTools.convertPrimitiveType(propertyType); - this.readMethod = readMethod; - this.writeMethod = writeMethod; - } - - /* Special serialization to handle method references */ - private void writeObject(java.io.ObjectOutputStream out) throws IOException { - out.defaultWriteObject(); - SerializerHelper.writeClass(out, propertyType); - - if (writeMethod != null) { - out.writeObject(writeMethod.getName()); - SerializerHelper.writeClass(out, writeMethod.getDeclaringClass()); - SerializerHelper.writeClassArray(out, - writeMethod.getParameterTypes()); - } else { - out.writeObject(null); - out.writeObject(null); - out.writeObject(null); - } - - if (readMethod != null) { - out.writeObject(readMethod.getName()); - SerializerHelper.writeClass(out, readMethod.getDeclaringClass()); - SerializerHelper.writeClassArray(out, - readMethod.getParameterTypes()); - } else { - out.writeObject(null); - out.writeObject(null); - out.writeObject(null); - } - } - - /* Special serialization to handle method references */ - private void readObject(java.io.ObjectInputStream in) throws IOException, - ClassNotFoundException { - in.defaultReadObject(); - try { - @SuppressWarnings("unchecked") - // business assumption; type parameters not checked at runtime - Class<BT> class1 = (Class<BT>) SerializerHelper.readClass(in); - propertyType = ReflectTools.convertPrimitiveType(class1); - - String name = (String) in.readObject(); - Class<?> writeMethodClass = SerializerHelper.readClass(in); - Class<?>[] paramTypes = SerializerHelper.readClassArray(in); - if (name != null) { - writeMethod = writeMethodClass.getMethod(name, paramTypes); - } else { - writeMethod = null; - } - - name = (String) in.readObject(); - Class<?> readMethodClass = SerializerHelper.readClass(in); - paramTypes = SerializerHelper.readClassArray(in); - if (name != null) { - readMethod = readMethodClass.getMethod(name, paramTypes); - } else { - readMethod = null; - } - } catch (SecurityException e) { - getLogger().log(Level.SEVERE, "Internal deserialization error", e); - } catch (NoSuchMethodException e) { - getLogger().log(Level.SEVERE, "Internal deserialization error", e); - } - } - - @Override - public String getName() { - return name; - } - - @Override - public Class<?> getPropertyType() { - return propertyType; - } - - @Override - public Property<?> createProperty(Object bean) { - return new MethodProperty<Object>(propertyType, bean, readMethod, - writeMethod); - } - - private static final Logger getLogger() { - return Logger.getLogger(MethodPropertyDescriptor.class.getName()); - } -} |