org.atmosphere.config.managed.Decoder Maven / Gradle / Ivy
/*
* Copyright 2015 Async-IO.org
*
* 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.atmosphere.config.managed;
/**
* Decode a message in order to invoke a class annotated with {@link org.atmosphere.config.service.ManagedService} with a method
* annotated with {@link org.atmosphere.config.service.Message}. For example:
*
public final class StringBufferDecoder implements Decoder {
@Override
public StringBuffer decode(String s) {
return new StringBuffer(s);
}
}
*
* will decode a String into a StringBuffer. The decoded object will then be used to invoke a method annotated with @Message
*
@Message(decoders = {StringBufferDecoder.class})
public void message(StringBuffer m) {
message.set(m.toString());
}
*
* You can chain Decoders. They will be invoked in the order they are defined and the last decoded value will be used to invoke the
* @Message annotated method.
* @param
* @param
* @author Jeanfrancois Arcand
*/
public interface Decoder {
/**
* Decode the specified object of type U into object of type T
*
* @param s a object of type U
* @return a new object of type T
*/
T decode(U s);
}