GithubHelp home page GithubHelp logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
Thanks for the bug report and patch.
I'm going to apply this patch to trunk before releasing next version (2.0.0).

Original comment by [email protected] on 9 Jan 2012 at 11:15

  • Changed state: Accepted

from simple-spring-memcached.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
Unfortunately attached patch will work only with bridge methods having the same 
amount and order of parameters as defined in @GenericsBridged annotation and 
with proper type of parameters.
Example:
{code}
public interface Generic<K,V> {

 //  amount and order of parameters and is the same as in @GenericsBridged and types of parameters are appropriate
  void set(K key, V value);

// wrong, method has different amount of parameters than @GenericsBridged
  V get(K key);

  // wrong, method has different amount of parameters than @GenericsBridged
  void put(K key, V value, boolean overwrite);

}


public interface Specific extends Generic<String, Integer> {}


//@GenericsBridged(classes={String.class, Integer.class})
public class SpecificImpl implements Specific {

  @BridgeMethodParams({String.class, Integer.class})
  public void set(String key, Integer value) {
  ....
  }

  @BridgeMethodParams({String.class})
  public Integer get(String key) {
  .....
  }

  @BridgeMethodParams({String.class, Integer.class, boolean.class}) 
  public void put(String key, Integer value, boolean overwrite) {
  ....
  }

}
{code}

One of the fix that I see is to use annotation on method. Dedicated annotation 
@BridgeMethodParams contains types of annotated method's parameters in 
appropriate order. The downside is that in same cases developer will have to 
put many @BridgeMethodParams in his class.

Original comment by [email protected] on 11 Jan 2012 at 6:54

from simple-spring-memcached.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
I agree with your idea to use annotation on method (even considering the 
downside). In this manner the code can work also in the situation that you 
explained.

Original comment by [email protected] on 11 Jan 2012 at 8:54

from simple-spring-memcached.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
This approach with @BridgeMethodParams doesn't work. If it worked it wouldn't 
be necessary because fetching directly @*Cache annotation would work also. The 
only solution that I see is to use type annotation with some mappings for each 
bridged method.

@BridgeMethodMappings({
@BridgeMethodMapping(name = "set", erasedParamTypes = {Object.class, 
Object.class}, targetParamTypes = {String.class, Integer.class}),
@BridgeMethodMapping(name = "get", erasedParamTypes = {Object.class}, 
targetParamTypes = {String.class}),
@BridgeMethodMapping(name = "put", erasedParamTypes = {Object.class, 
Object.class, boolean.class}, targetParamTypes = {String.class, Integer.class, 
boolean.class})
)}
public class SpecificImpl implements Specific {
.....
}

This requires many additional annotations and knowledge about java type erasure.

Original comment by [email protected] on 11 Jan 2012 at 7:31

from simple-spring-memcached.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
Code in trunk.

Original comment by [email protected] on 31 Jan 2012 at 8:53

  • Changed state: Fixed

from simple-spring-memcached.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.