-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from admd/add-module-name-information
Refactored some code and added module name information to Call classes
- Loading branch information
Showing
7 changed files
with
119 additions
and
36 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/main/java/com/suse/salt/netapi/calls/AbstractCall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.suse.salt.netapi.calls; | ||
|
||
import com.google.gson.reflect.TypeToken; | ||
import com.suse.salt.netapi.utils.ClientUtils; | ||
|
||
/** | ||
* Abstract class for all function calls in salt. | ||
* | ||
* @param <R> the return type of the called function | ||
*/ | ||
public abstract class AbstractCall<R> implements Call<R> { | ||
|
||
private final String moduleName; | ||
private final String functionName; | ||
private final TypeToken<R> returnType; | ||
|
||
AbstractCall(String functionName, TypeToken<R> returnType) { | ||
this.moduleName = ClientUtils.getModuleNameFromFunction(functionName); | ||
this.functionName = functionName; | ||
this.returnType = returnType; | ||
} | ||
|
||
AbstractCall(String moduleName, String functionName, TypeToken<R> returnType) { | ||
this.moduleName = moduleName; | ||
this.functionName = functionName; | ||
this.returnType = returnType; | ||
} | ||
|
||
/** | ||
* Returns the module name | ||
*/ | ||
public String getModuleName() | ||
{ | ||
return moduleName; | ||
} | ||
|
||
/** | ||
* Return the function name | ||
* @return functionName | ||
*/ | ||
String getFunctionName() { | ||
return functionName; | ||
} | ||
|
||
/** | ||
* Reurn the type | ||
* @return returnType | ||
*/ | ||
public TypeToken<R> getReturnType() { | ||
return returnType; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters