Click here to Skip to main content
16,019,768 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
public <<requestType>>Details createRequest()
{
<<requestType>>Details request = new <<requestType>>Impl();
// populate request attributes
return request;
}

what does it mean in java
Posted

1 solution

Hello,

The code you have presented has no meaning. To learn more about Generics please have a look at this[^] documentation.

You can write a single generic method declaration that can be called with arguments of different types. Based on the types of the arguments passed to the generic method, the compiler handles each method call appropriately. Following are the rules to define Generic Methods:

  • All generic method declarations have a type parameter section delimited by angle brackets (< and >) that precedes the method's return type ( < E > in the next example).
  • Each type parameter section contains one or more type parameters separated by commas. A type parameter, also known as a type variable, is an identifier that specifies a generic type name.
  • The type parameters can be used to declare the return type and act as placeholders for the types of the arguments passed to the generic method, which are known as actual type arguments.
  • A generic method's body is declared like that of any other method. Note that type parameters can represent only reference types, not primitive types (like int, double and char).

Example:
Java
 // generic method printArray                         
public static < E > void printArray( E[] inputArray )
{
    // Display array elements              
    for ( E element : inputArray ){        
        System.out.printf( "%s ", element );
    }
    System.out.println();
}

Regards,
 
Share this answer
 
Comments
Member 10359119 25-Oct-13 2:47am    
public PatientVerificationRequestDetails createPatientVerificationRequestOpvDetails() {
PatientVerificationRequestDetails request = new PatientVerificationRequestDetailsImpl();
Calendar todaysDate =
new GregorianCalendar(TimeZone.getTimeZone("default"));
Calendar earliestDate = new GregorianCalendar(TimeZone.getTimeZone("default"));
earliestDate.set(2009,7,1);
request.setEarliestDateOfService(earliestDate);
request.setOPVTypeCde("OPV");
// add patient details to voucher 1
MedicarePersonDetails patient = new MedicarePersonDetailsImpl();
patient.setGender("M");
Calendar dob = new GregorianCalendar(TimeZone.getTimeZone("default"));
dob.set(1958,01,31);
patient.setDateOfBirth(dob);
IdentityDetails identity = new IdentityDetailsImpl();
identity.setFirstName("Bailey");
identity.setLastName("O'Work");
patient.setIdentity(identity);
IdentityDetails alias = new IdentityDetailsImpl();
alias.setFirstName("Alias1");
alias.setLastName("Alias2");
patient.setAlias(alias);
MembershipDetails member = new MembershipDetailsImpl();
member.setMemberRefNum("1");
member.setMemberNum("0123456789");
patient.setMedicare(member);
MembershipDetails membership = new MembershipDetailsImpl();
membership.setMemberRefNum("5");
membership.setMemberNum("123456789012345");
membership.setOrganisation("CCA");
patient.setHealthFund(membership);
request.setPatient(patient);
ProviderDetails provider = new ProviderDetailsImpl();
provider.setProviderNum("4444444J");
request.setProvider(provider);
return request;
}

what is new PatientVerificationRequestDetailsImpl();
new MembershipDetailsImpl();
any suggestion
Prasad Khandekar 25-Oct-13 2:59am    
PatientVerificationRequestDetails, MembershipDetails are the interfaces and PatientVerificationRequestDetailsImpl, MembershipDetailsImpl are the implementations of those interfaces (Concrete Classes).

Regards,
Member 10359119 25-Oct-13 3:22am    
can you give me one example of MembershipDetailsImpl implementations of that interfaces
really appreciable
Prasad Khandekar 25-Oct-13 3:47am    
Just create a new class as shown below

public class MyMembershipDetails implements MembershipDetails {
....
}

If you are using Eclipse for the development. Then In the Package Explorer right click on any package where you want to put the implementation and choose New->Class. In the resulting window Type in your desired class name in the Name textbox. Click On Add button next to Interfaces combo and type MembershipDetails in the Choose Interfaces textbox. The matched interface should appear in the Matiching Items. just docuble click to select it. Now in the New Java Class dialog tick the checkbox named Inherited abstract method and hit ok to generate the class. You will get a class with all the methods to be implemented.
Member 10359119 25-Oct-13 4:36am    
Thanks sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900