When defining mobile service interfaces, the server-side cannot use the full Java syntax. This restriction exists because of limitations in mobile development environments, especially iOS, and it helps keep interface definitions simple.
The interface definition specifications cover three types of definitions:
Specifications for natively supported data classes: Supported native Java classes and wrapper classes.
Specifications for user interface classes: User-defined interfaces that contain method declarations for API calls.
Specifications for user-defined entity classes: User-defined entity classes that contain field declarations. These classes are referenced by method parameters or return values in interface classes, or by other user-defined entity classes.
Specifications for internally supported data classes
Unsupported data types
Do not use multilayer nesting for container types.
Do not use `List` or `Map` without specifying generics.
Do not use an array type as a generic for `List` or `Map`.
Single bytes are not supported. However, byte arrays (`byte[]`) are supported.
Do not use object arrays. Use a list instead.
Do not name properties `data` or `description`. These names conflict with iOS properties.
The key for a `Map` must be a `String`.
Do not use abstract classes as types.
Do not use interface classes as types.
Incorrect examples:
public class Req {
private Map<String,List<Person>> map; // Do not use multilayer nesting for container types.
private List<Map<Person>> list; // Do not use multilayer nesting for container types.
private List list1; // Specify generics for List or Map.
private Map map1; // Specify generics for List or Map.
private List<Person[]> listArray; // Do not use an array type as a generic for List or Map.
private byte b; // Single bytes are not supported.
private Person[] personArray; // Do not use object arrays. Use a list instead.
private String description; // Do not name a property description.
}Supported data types
boolean, char, double, float, int, long, short
java.lang.Boolean
java.lang.Character
java.lang.Double
java.lang.Float
java.lang.Integer
java.lang.Long
java.lang.Short
java.lang.String
java.util.List (Note: You must specify type parameters. Do not use concrete child classes.)
java.util.Map (Note: You must specify type parameters. Do not use concrete child classes. The key type must be String.)
Enum
byte[]Correct format:
public class Req {
private String s = "ss";
private int i;
private double d;
private Long l;
private long l1;
private boolean b;
private List<String> stringList;
private List<Person> personList;
private Map<String,Person> map;
private byte[] bytes;
private EnumType type;
}
public class Person {
private String name;
private int age;
}Specifications for user interface classes
Method parameters
Do not reference:
Enumeration types
Generics other than `Map`, `List`, and `Set`
Abstract classes
Interface classes
Arrays of primitive types
You can reference:
Concrete entity classes. The reference data type must match the actual object type. Do not use a parent class reference to point to a child class object.
Natively supported data classes. Do not nest collection types such as arrays, `Map`, `List`, or `Set`.
The following are incorrect examples:
Map<String,String[]>
Map<String,List<Person>> // Person is a concrete entity class.
List<Map<String,Person>>
List<Person[]>Method return values
Do not reference:
Enumeration types
Generics other than `Map`, `List`, and `Set`
Abstract classes
Interface classes
Arrays of primitive types
You can reference:
Concrete data classes. The reference data type must match the actual object type. Do not use a parent class reference to point to a child class object. For example, do not use an `Object` reference to point to other objects.
ImportantIf the parent class is a concrete class, the code generation tool cannot detect this fault.
Natively supported data classes, as defined at the beginning of this topic. Do not nest collection types such as arrays, `Map`, `List`, or `Set`. For more information, see the examples above.
Method definitions
Use the `@OperationType` annotation. The code generation tool ignores methods without this annotation.
Do not overload methods.
Code generation tool limitations
The tool allows inheritance in interface class definitions, but it merges the class hierarchy.
The tool allows but ignores variables defined in interface classes.
The tool allows but ignores exception declarations in interface methods.
A source file can contain only one interface class definition. It cannot contain other class definitions, such as inner or anonymous classes.
The interface class and its referenced types must be either natively supported data classes or have definitions available in the source code.
Specifications for user-defined entity classes
Field definitions
Do not reference:
Enumeration types
Generics other than `Map`, `List`, and `Set`
Abstract classes
Interface classes
Arrays of primitive types
You can reference:
Concrete entity classes. The reference data type must match the actual object type. Do not use a parent class reference to point to a child class object.
Natively supported data classes. Do not nest collection types such as arrays, `Map`, `List`, or `Set`. For more information, see the examples above.
Properties with the `transient` modifier are ignored.
Constants defined as `final static int`. Other constants or static variables that do not meet this requirement are ignored.
NoteAvoid defining member variables that start with
is.
Class definitions
Classes can inherit from other entity classes.
Method declarations are ignored. The code generation tool automatically generates setter and getter methods based on the entity class fields.
Code generation tool limitations
Declare only one property per line.
The tool allows but ignores interfaces implemented by user-defined entity classes.
A source file can contain only one user-defined entity class definition. It cannot contain other class definitions, such as inner or anonymous classes.
The entity class and its referenced types must be either natively supported data classes or have definitions available in the source code.