Tagged Questions
4
votes
0answers
57 views
Use generic to store common supertype in Java
Suppose I have a method "mix" that takes two Lists of possibly different types T and S and returns a single List containing the elements of both. For type-safety, I'd like to specify that the returned ...
3
votes
0answers
43 views
Type safety warning when parameter is parameterized descendant of parametrized class
I have a method with signature:
public static <T, E extends PxViewFull<T> > E create(Class<T> dtoClass, Class<E> viewClass)
When I call it for parametrized second parameter ...
3
votes
0answers
252 views
JAXB Bindings File Sets @XmlElement type to String instead of XMLGregorianCalendar
I'm trying to create an XmlAdapter that takes in an XMLGregorianCalendar and outputs an XMLGregorianCalendar. The purpose is simlply to remove timezone data from the element when unmarshalling data.
...
2
votes
0answers
155 views
Jersey JSON marshalling of nested generic produces null
Having an issue trying to marshall into JSON a HashMap nested in a List using Jersey 1.11.
Here's a snippet of a Jersey endpoint which produces MediaType.APPLICATION_JSON via the returned Response ...
1
vote
0answers
21 views
Google Guice - Use generic as parameter of injected field
I want to use a generic parameter of a class for a field that is injected, but guice complains about a unbound key. Is it possible to inject the field in Test2?
Example:
public static class ...
1
vote
0answers
54 views
why java returns java.util.LinkedHashMap when … complex
my code is as below...
@ResponseBody
@RequestMapping(value ="/updateAll", method=RequestMethod.POST)
public JSONObject update( @RequestBody List<T> list){
try{
T entity = ...
1
vote
0answers
42 views
Best way to retrofit existing code w/ generics and chaining of protected methods?
I'm retrofitting an existing hierarchy and hope to use a factory or at least a generic constructor and (eventually) immutable builder patterns (JB P.14). The methods that set fields return void - it ...
1
vote
0answers
68 views
Spring Security ACL - @PreAuthorize Generics & Interface
Using Spring ACL with @PreAuthorize annotations on Interfaces which use Generics does not seem to work.
Eg; I have an interface using generics;
public interface MyService<T> {
...
1
vote
0answers
49 views
Java nested wildcard bound types multiple times or as generic type parameter
I have a class with a bounded type parameter with nested wildcard bounded types. In the class I need to use the types of the bound nested parameters in multiple methods. Is there a way to define the ...
1
vote
0answers
72 views
Generic return type method: How do I avoid BOTH unchecked cast warnings and the need to cast the return value when calling the method?
I am building out a Selenium automation framework using the Page Object design pattern and I have a method that returns one of three page types. They all extend SecuredPage, which extends Page. I am ...
1
vote
0answers
34 views
Is it possible to fix library parametrized type implementation on the client side to prevent unchecked warning?
I have used JSON library from external provider (google code project) which have a class JSONArray defined this way:
public class JSONArray extends ArrayList implements List , ... {
So it has a ...
1
vote
0answers
53 views
Netbeans Generics Bug using FEST, Java?
I have the following non-generic method for getting a JListFixture using FEST:
public static JListFixture getJListFixtureNonGeneric(final FrameFixture frame) {
return frame.list(new ...
1
vote
0answers
28 views
Stop Eclipse from sliding curly braces way to the right for methods returning generic types
I configured Eclipse to adhere to my employer's code style, but one tiny detail isn't working right: I told it to put all braces on the next line, unindented, and line wrap method parameters, aligning ...
1
vote
0answers
73 views
Bidirectional Object-Conversation
I have to process JPA-entity objects to JAXB-annotated objects and vis versa.
The two class types look like this:
@Entity
public Entity{
private String fieldA;
private int fieldB;
private Entity2 ...
1
vote
0answers
203 views
java generics and .class (Solved)
I have a custom typeHandler for myBatis, defined as
@MappedJdbcTypes(JdbcType.VARCHAR)
public class JsonTypeHandler<T> extends BaseTypeHandler<T> {
.....
}
now i need to pass it in ...