// Path: src/main/java/org/easycassandra/persistence/cassandra/Customizable.java
// class DefaultCustmomizable implements Customizable {
// 
//     public ByteBuffer read(Object object) {
// 
//         try {
//             isSerializable(object);
//             ByteArrayOutputStream stream = new ByteArrayOutputStream();
//             ObjectOutputStream storeObject = new ObjectOutputStream(stream);
//             storeObject.writeObject(object);
//             storeObject.flush();
//             storeObject.close();
// 
//             return ByteBuffer.wrap(stream.toByteArray());
//         } catch (IOException exception) {
//             Logger.getLogger(DefaultCustmomizable.class.getName()).severe(
//                     "An error heppend when DefaultCustmomizable try read or "
//                     + "serialize the object "
//                             + object.getClass().getName() + " "
//                             + exception.getMessage());
//         }
// 
//         return null;
//     }
// 
//     private void isSerializable(Object object) {
//         if (!(object instanceof Serializable)) {
//             StringBuilder mensageErro = new StringBuilder();
//             mensageErro.append("the class ").append(
//                     object.getClass().getName());
//             mensageErro.append(" should implements java.io.Serializable");
//             throw new DefaultCustmomizableException(mensageErro.toString());
//         }
// 
//     }
// 
//     public Object write(ByteBuffer byteBuffer) {
// 
//         try {
//             byte[] result = new byte[byteBuffer.remaining()];
//             byteBuffer.get(result);
//             InputStream inputStream = new ByteArrayInputStream(result);
//             ObjectInputStream objLeitura = new ObjectInputStream(
//                     inputStream);
//             return objLeitura.readObject();
//         } catch (Exception exception) {
//             Logger.getLogger(DefaultCustmomizable.class.getName())
//                     .severe("An error heppend when DefaultCustmomizable "
//                             + "try write and deserialize an object "
//                             + exception.getMessage());
//         }
//         return null;
//     }
// }


import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.easycassandra.persistence.cassandra.Customizable.DefaultCustmomizable;

/*
 * Copyright 2013 Otávio Gonçalves de Santana (otaviojava)
 *  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 org.easycassandra;


/**
 * This notation indicates which the field has a storage's way custom.
 * @author osantana
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface CustomData {

    /**
     * The class to custom a storage, the class should implements the
     * Customizable and has default constructor. the default is
     * {@link DefaultCustmomizable}
     * the class whose implements Customizable interface
     */

// Path: src/main/java/org/easycassandra/persistence/cassandra/Customizable.java
// class DefaultCustmomizable implements Customizable {
// 
//     public ByteBuffer read(Object object) {
// 
//         try {
//             isSerializable(object);
//             ByteArrayOutputStream stream = new ByteArrayOutputStream();
//             ObjectOutputStream storeObject = new ObjectOutputStream(stream);
//             storeObject.writeObject(object);
//             storeObject.flush();
//             storeObject.close();
// 
//             return ByteBuffer.wrap(stream.toByteArray());
//         } catch (IOException exception) {
//             Logger.getLogger(DefaultCustmomizable.class.getName()).severe(
//                     "An error heppend when DefaultCustmomizable try read or "
//                     + "serialize the object "
//                             + object.getClass().getName() + " "
//                             + exception.getMessage());
//         }
// 
//         return null;
//     }
// 
//     private void isSerializable(Object object) {
//         if (!(object instanceof Serializable)) {
//             StringBuilder mensageErro = new StringBuilder();
//             mensageErro.append("the class ").append(
//                     object.getClass().getName());
//             mensageErro.append(" should implements java.io.Serializable");
//             throw new DefaultCustmomizableException(mensageErro.toString());
//         }
// 
//     }
// 
//     public Object write(ByteBuffer byteBuffer) {
// 
//         try {
//             byte[] result = new byte[byteBuffer.remaining()];
//             byteBuffer.get(result);
//             InputStream inputStream = new ByteArrayInputStream(result);
//             ObjectInputStream objLeitura = new ObjectInputStream(
//                     inputStream);
//             return objLeitura.readObject();
//         } catch (Exception exception) {
//             Logger.getLogger(DefaultCustmomizable.class.getName())
//                     .severe("An error heppend when DefaultCustmomizable "
//                             + "try write and deserialize an object "
//                             + exception.getMessage());
//         }
//         return null;
//     }
// }


// Path: src/main/java/org/easycassandra/CustomData.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.easycassandra.persistence.cassandra.Customizable.DefaultCustmomizable;

/*
 * Copyright 2013 Otávio Gonçalves de Santana (otaviojava)
 *  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 org.easycassandra;


/**
 * This notation indicates which the field has a storage's way custom.
 * @author osantana
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface CustomData {

    /**
     * The class to custom a storage, the class should implements the
     * Customizable and has default constructor. the default is
     * {@link DefaultCustmomizable}
     * the class whose implements Customizable interface
     */

	 Class<?>  classCustmo() default DefaultCustmomizable.class;
