code
stringlengths
73
34.1k
label
stringclasses
1 value
public void add(Widget w, String tabText, boolean asHTML) { insert(w, tabText, asHTML, getWidgetCount()); }
java
public static <T extends MPBase> T manage(Topic topic, String id) throws MPException { if (topic == null || id == null) { throw new MPException("Topic and Id can not be null in the IPN request"); } T resourceObject = null; Class clazz = null; Method m...
java
public <T extends MPBase> T getByIndex(int index) { T resource = (T) _resourceArray.get(index); return resource; }
java
public <T extends MPBase> T getById(String id) throws MPException { T resource = null; for (int i = 0; i < _resourceArray.size(); i++) { resource = getByIndex(i); try { Field field = resource.getClass().getDeclaredField("id"); field.setAccessible(t...
java
protected <T extends MPBase> T processMethod(String methodName, Boolean useCache) throws MPException { HashMap<String, String> mapParams = null; T resource = processMethod(this.getClass(), (T)this, methodName, mapParams, useCache); fillResource(resource, this); return (T)this; }
java
protected static <T extends MPBase> T processMethod(Class clazz, String methodName, String param1, Boolean useCache) throws MPException { HashMap<String, String> mapParams = new HashMap<String, String>(); mapParams.put("param1", param1); return processMethod(clazz, null, methodName, mapParams, ...
java
private static MPApiResponse callApi( HttpMethod httpMethod, String path, PayloadType payloadType, JsonObject payload, Collection<Header> colHeaders, int retries, int connectionTimeout, int socketTimeout, Boolean...
java
protected static <T extends MPBase> T fillResourceWithResponseData(T resource, MPApiResponse response) throws MPException { if (response.getJsonElementResponse() != null && response.getJsonElementResponse().isJsonObject()) { JsonObject jsonObject = (JsonObject) response.getJsonElemen...
java
protected static <T extends MPBase> ArrayList<T> fillArrayWithResponseData(Class clazz, MPApiResponse response) throws MPException { ArrayList<T> resourceArray = new ArrayList<T>(); if (response.getJsonElementResponse() != null) { JsonArray jsonArray = MPCoreUtils.getArrayFromJsonElement(res...
java
private static <T extends MPBase> T fillResource(T sourceResource, T destinationResource) throws MPException { Field[] declaredFields = destinationResource.getClass().getDeclaredFields(); for (Field field : declaredFields) { try { Field originField = sourceResource.getClass()...
java
private static <T extends MPBase> T cleanResource(T resource) throws MPException { Field[] declaredFields = resource.getClass().getDeclaredFields(); for (Field field : declaredFields) { try { field.setAccessible(true); field.set(resource, null); ...
java
private static Collection<Header> getStandardHeaders() { Collection<Header> colHeaders = new Vector<Header>(); colHeaders.add(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); colHeaders.add(new BasicHeader(HTTP.USER_AGENT, "MercadoPago Java SDK/1.0.10")); colHeaders.add(new Basic...
java
private static <T extends MPBase> JsonObject generatePayload(HttpMethod httpMethod, T resource) { JsonObject payload = null; if (httpMethod.equals(HttpMethod.POST) || (httpMethod.equals(HttpMethod.PUT) && resource._lastKnownJson == null)) { payload = MPCoreUtils.getJsonFromRe...
java
private static HashMap<String, Object> getRestInformation(AnnotatedElement element) throws MPException{ if (element.getAnnotations().length == 0) { throw new MPException("No rest method found"); } HashMap<String, Object> hashAnnotation = new HashMap<String, Object>(); for (A...
java
private static AnnotatedElement getAnnotatedMethod(Class clazz, String methodName) throws MPException { for (Method method : clazz.getDeclaredMethods()) { if (method.getName().equals(methodName) && method.getDeclaredAnnotations().length > 0) { return method; ...
java
public static String getAccessToken() throws MPException { if (StringUtils.isEmpty(MercadoPago.SDK.getClientId()) || StringUtils.isEmpty(MercadoPago.SDK.getClientSecret())) { throw new MPException("\"client_id\" and \"client_secret\" can not be \"null\" when getting the \"access_toke...
java
private void parseRequest(HttpMethod httpMethod, HttpRequestBase request, JsonObject payload) throws MPException { this.method = httpMethod.toString(); this.url = request.getURI().toString(); if (payload != null) { this.payload = payload.toString(); } }
java
private void parseResponse(HttpResponse response) throws MPException { this.statusCode = response.getStatusLine().getStatusCode(); this.reasonPhrase = response.getStatusLine().getReasonPhrase(); if (response.getEntity() != null) { HttpEntity respEntity = response.getEntity(); ...
java
public static <T extends MPBase> boolean validate(T objectToValidate) throws MPValidationException { Collection<ValidationViolation> colViolations = validate(new Vector<ValidationViolation>(), objectToValidate); if (!colViolations.isEmpty()) { throw new MPValidationException(colViolations); ...
java
static Field[] getAllFields(Class<?> type) { List<Field> fields = new ArrayList<Field>(); for (Class<?> clazz = type; clazz != null; clazz = clazz.getSuperclass()) { if (clazz == MPBase.class || clazz == Object.class) { break; } fie...
java
public static <T extends MPBase> JsonObject getJsonFromResource(T resourceObject) { return (JsonObject) gson.toJsonTree(resourceObject); }
java
public static <T> T getResourceFromJson(Class clazz, JsonObject jsonEntity) { return (T) gson.fromJson(jsonEntity, clazz); }
java
public static String inputStreamToString(InputStream is) throws MPException { String value = ""; if (is != null) { try { ByteArrayOutputStream result = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int length; whi...
java
public static boolean validateUrl(String url) { String[] schemes = {"https"}; UrlValidator urlValidator = new UrlValidator(schemes); return urlValidator.isValid(url); }
java
static JsonArray getArrayFromJsonElement(JsonElement jsonElement) { JsonArray jsonArray = null; if (jsonElement.isJsonArray()) { jsonArray = jsonElement.getAsJsonArray(); } else if (jsonElement.isJsonObject() && ((JsonObject) jsonElement).get("results") != null && ...
java
public MPApiResponse executeRequest(HttpMethod httpMethod, String uri, PayloadType payloadType, JsonObject payload, Collection<Header> colHeaders, int retries, int connectionTimeout, int socketTimeout) throws MPRestException { HttpClient httpClient = null; try { httpClient = getC...
java
private HttpClient getClient(int retries, int connectionTimeout, int socketTimeout) { HttpClient httpClient = new DefaultHttpClient(); HttpParams httpParams = httpClient.getParams(); // Retries if (retries > 0) { DefaultHttpRequestRetryHandler retryHandler = new DefaultHttpR...
java
private HttpEntity normalizePayload(PayloadType payloadType, JsonObject payload, Collection<Header> colHeaders) throws MPRestException { BasicHeader header = null; HttpEntity entity = null; if (payload != null) { if (payloadType == PayloadType.JSON) { header = new Bas...
java
private HttpRequestBase getRequestMethod(HttpMethod httpMethod, String uri, HttpEntity entity) throws MPRestException { if (httpMethod == null) { throw new MPRestException("HttpMethod must be \"GET\", \"POST\", \"PUT\" or \"DELETE\"."); } if (StringUtils.isEmpty(uri)) thr...
java
private static HashMap<String, MPApiResponse> getMapCache() { if (cache == null || cache.get() == null) { cache = new SoftReference(new HashMap<String, MPApiResponse>()); } return cache.get(); }
java
static void addToCache(String key, MPApiResponse response) { HashMap<String, MPApiResponse> mapCache = getMapCache(); mapCache.put(key, response); }
java
static MPApiResponse getFromCache(String key) { HashMap<String, MPApiResponse> mapCache = getMapCache(); MPApiResponse response = null; try { response = mapCache.get(key).clone(); } catch (Exception ex) { // Do nothing } if (response != null) { ...
java
static void removeFromCache(String key) { HashMap<String, MPApiResponse> mapCache = getMapCache(); mapCache.remove(key); }
java
private void loadPropFile(String propFileName) throws IOException, Error { InputStream inputStream = null; try { inputStream = getClass().getClassLoader().getResourceAsStream(propFileName); if (inputStream != null) { this.prop.load(inputStream); LOGGER.debug("properties file " + propFileName + " load...
java
private String loadStringProperty(String propertyKey) { String propValue = prop.getProperty(propertyKey); if (propValue != null) { propValue = propValue.trim(); } return propValue; }
java
@SuppressWarnings("unused") private Boolean loadBooleanProperty(String propertyKey) { String booleanPropValue = prop.getProperty(propertyKey); if (booleanPropValue != null) { return Boolean.parseBoolean(booleanPropValue.trim()); } else { return null; } }
java
@SuppressWarnings("unused") private List<String> loadListProperty(String propertyKey) { String arrayPropValue = prop.getProperty(propertyKey); if (arrayPropValue != null && !arrayPropValue.isEmpty()) { String [] values = arrayPropValue.trim().split(","); for (int i = 0; i < values.length; i++) { values[i...
java
@SuppressWarnings("unused") private URL loadURLProperty(String propertyKey) { String urlPropValue = prop.getProperty(propertyKey); if (urlPropValue == null || urlPropValue.isEmpty()) { return null; } else { try { return new URL(urlPropValue.trim()); } catch (MalformedURLException e) { LOGGER.e...
java
public String get(String key) { try { Field field; field = this.getClass().getField(key); return (String) field.get(this); } catch(NoSuchFieldException e) { return (String) antifraud_info.get(key); } catch(IllegalAccessException e) { re...
java
public void getAccessToken() throws OAuthSystemException, OAuthProblemException { cleanError(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); //OAuthClient oAuthClient = new OAuthClient(httpClient); OAuthClientRequest request = OAuthClientRequest .tokenLocation(settings.getURL(C...
java
public void refreshToken() throws OAuthSystemException, OAuthProblemException { cleanError(); if (accessToken == null || refreshToken == null) { throw new OAuthRuntimeException("Access token ot Refresh token not provided"); } OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAut...
java
public void revokeToken() throws OAuthSystemException, OAuthProblemException { cleanError(); if (accessToken == null) { throw new OAuthRuntimeException("Access token not provided"); } OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClientRequest request = OAuthClientReques...
java
public RateLimit getRateLimit() throws OAuthSystemException, OAuthProblemException { cleanError(); prepareToken(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClient oAuthClient = new OAuthClient(httpClient); OAuthClientRequest bearerRequest = new OAuthBearerClientRequest...
java
public OneLoginResponse<User> getUsersBatch(int batchSize) throws OAuthSystemException, OAuthProblemException, URISyntaxException { return getUsersBatch(batchSize, null); }
java
public List<App> getUserApps(long id) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); URIBuilder url = new URIBuilder(settings.getURL(Constants.GET_APPS_FOR_USER_URL, Long.toString(id))); OneloginURLConnectionClient httpClient = new OneloginURLConnectionC...
java
public List<Integer> getUserRoles(long id) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); URIBuilder url = new URIBuilder(settings.getURL(Constants.GET_ROLES_FOR_USER_URL, Long.toString(id))); OneloginURLConnectionClient httpClient = new OneloginURLConne...
java
public User createUser(Map<String, Object> userParams) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClient oAuthClient = new OAuthClient(httpClient); URIBuilder url = ne...
java
public Object createSessionLoginToken(Map<String, Object> queryParams, String allowedOrigin) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClient oAuthClient = new OAuthClie...
java
public Object createSessionLoginToken(Map<String, Object> queryParams) throws OAuthSystemException, OAuthProblemException, URISyntaxException { return createSessionLoginToken(queryParams, null); }
java
public Boolean assignRoleToUser(long id, List<Long> roleIds) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClient oAuthClient = new OAuthClient(httpClient); URIBuilder ur...
java
public Boolean setPasswordUsingHashSalt(long id, String password, String passwordConfirmation, String passwordAlgorithm) throws OAuthSystemException, OAuthProblemException, URISyntaxException { return setPasswordUsingHashSalt(id, password, passwordConfirmation, passwordAlgorithm, null); }
java
public Boolean logUserOut(long id) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClient oAuthClient = new OAuthClient(httpClient); URIBuilder url = new URIBuilder(setting...
java
public List<EventType> getEventTypes() throws URISyntaxException, ClientProtocolException, IOException { URIBuilder url = new URIBuilder(settings.getURL(Constants.GET_EVENT_TYPES_URL)); CloseableHttpClient httpclient = HttpClients.createDefault(); HttpGet httpGet = new HttpGet(url.toString()); httpGet.setHeader...
java
public List<Event> getEvents(HashMap<String, String> queryParameters, int maxResults) throws OAuthSystemException, OAuthProblemException, URISyntaxException { ExtractionContext context = getResource(queryParameters, Constants.GET_EVENTS_URL); OneloginOAuthJSONResourceResponse oAuthResponse = null; String afterCu...
java
public Event getEvent(long id) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); URIBuilder url = new URIBuilder(settings.getURL(Constants.GET_EVENT_URL, Long.toString(id))); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAut...
java
public void createEvent(Map<String, Object> eventParams) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClient oAuthClient = new OAuthClient(httpClient); URIBuilder url = ...
java
public OneLoginResponse<Group> getGroupsBatch(HashMap<String, String> queryParameters, int batchSize, String afterCursor) throws OAuthSystemException, OAuthProblemException, URISyntaxException { ExtractionContext context = extractResourceBatch(queryParameters, batchSize, afterCursor, Constants.GET_GROUPS_URL); L...
java
public List<AuthFactor> getFactors(long userId) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); URIBuilder url = new URIBuilder(settings.getURL(Constants.GET_FACTORS_URL, userId)); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClie...
java
public OTPDevice enrollFactor(long userId, long factorId, String displayName, String number) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); URIBuilder url = new URIBuilder(settings.getURL(Constants.ENROLL_FACTOR_URL, userId)); OneloginURLConnectionCl...
java
public Boolean removeFactor(long userId, long deviceId) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); URIBuilder url = new URIBuilder(settings.getURL(Constants.REMOVE_FACTOR_URL, userId, deviceId)); OneloginURLConnectionClient httpClient = new Onelo...
java
public String generateInviteLink(String email) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClient oAuthClient = new OAuthClient(httpClient); URIBuilder url = new URIBui...
java
public Boolean sendInviteLink(String email, String personalEmail) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClient oAuthClient = new OAuthClient(httpClient); URIBuild...
java
public Boolean sendInviteLink(String email) throws OAuthSystemException, OAuthProblemException, URISyntaxException { return sendInviteLink(email, null); }
java
public List<EmbedApp> getEmbedApps(String token, String email) throws URISyntaxException, ClientProtocolException, IOException, ParserConfigurationException, SAXException, XPathExpressionException { cleanError(); URIBuilder url = new URIBuilder(Constants.EMBED_APP_URL); url.addParameter("token", token); url.add...
java
public List<Privilege> getPrivileges() throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); URIBuilder url = new URIBuilder(settings.getURL(Constants.LIST_PRIVILEGES_URL)); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClie...
java
public Privilege createPrivilege(String name, String version, List<?> statements) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClient oAuthClient = new OAuthClient(httpClie...
java
public Privilege getPrivilege(String id) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); URIBuilder url = new URIBuilder(settings.getURL(Constants.GET_PRIVILEGE_URL, id)); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuth...
java
public Boolean deletePrivilege(String id) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClient oAuthClient = new OAuthClient(httpClient); URIBuilder url = new URIBuilder(...
java
public List<Long> getRolesAssignedToPrivileges(String id, int maxResults) throws OAuthSystemException, OAuthProblemException, URISyntaxException { ExtractionContext context = getResource(Constants.GET_ROLES_ASSIGNED_TO_PRIVILEGE_URL, id); OneloginOAuth2JSONResourceResponse oAuth2Response = null; String afterCurs...
java
public OneLoginResponse<Long> getRolesAssignedToPrivilegesBatch(String id, int batchSize, String afterCursor) throws OAuthSystemException, OAuthProblemException, URISyntaxException { ExtractionContext context = extractResourceBatch((Object)id, batchSize, afterCursor, Constants.GET_ROLES_ASSIGNED_TO_PRIVILEGE_URL);...
java
public Boolean assignUsersToPrivilege(String id, List<Long> userIds) throws OAuthSystemException, OAuthProblemException, URISyntaxException { cleanError(); prepareToken(); OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient(); OAuthClient oAuthClient = new OAuthClient(httpClient); URIBu...
java
public void called(Matcher<Integer> numberOfCalls) { Rule rule = ruleBuilder.toRule(); int matchingCalls = (int)requests.stream() .filter(req -> rule.matches(req)) .count(); if (!numberOfCalls.matches(matchingCalls)) { throw new IllegalStateException(...
java
public HttpClientResponseBuilder withHeader(String name, String value) { Action lastAction = newRule.getLastAction(); HeaderAction headerAction = new HeaderAction(lastAction, name, value); newRule.overrideLastAction(headerAction); return this; }
java
public HttpClientResponseBuilder withStatus(int statusCode) { Action lastAction = newRule.getLastAction(); StatusResponse statusAction = new StatusResponse(lastAction, statusCode); newRule.overrideLastAction(statusAction); return this; }
java
public HttpClientResponseBuilder withCookie(String cookieName, String cookieValue) { Action lastAction = newRule.getLastAction(); CookieAction cookieAction = new CookieAction(lastAction, cookieName, cookieValue); newRule.overrideLastAction(cookieAction); return this; }
java
public HttpClientResponseBuilder doReturn(int statusCode, String response) { return doReturn(statusCode, response, Charset.forName("UTF-8")); }
java
public HttpClientResponseBuilder doThrowException(IOException exception) { newRule.addAction(new ExceptionAction(exception)); return new HttpClientResponseBuilder(newRule); }
java
static FullEntity<?>[] toNativeFullEntities(List<?> entities, DefaultEntityManager entityManager, Marshaller.Intent intent) { FullEntity<?>[] nativeEntities = new FullEntity[entities.size()]; for (int i = 0; i < entities.size(); i++) { nativeEntities[i] = (FullEntity<?>) Marshaller.marshal(entityMan...
java
static Entity[] toNativeEntities(List<?> entities, DefaultEntityManager entityManager, Marshaller.Intent intent) { Entity[] nativeEntities = new Entity[entities.size()]; for (int i = 0; i < entities.size(); i++) { nativeEntities[i] = (Entity) Marshaller.marshal(entityManager, entities.get(i), intent...
java
static Entity incrementVersion(Entity nativeEntity, PropertyMetadata versionMetadata) { String versionPropertyName = versionMetadata.getMappedName(); long version = nativeEntity.getLong(versionPropertyName); return Entity.newBuilder(nativeEntity).set(versionPropertyName, ++version).build(); }
java
static void rollbackIfActive(Transaction transaction) { try { if (transaction != null && transaction.isActive()) { transaction.rollback(); } } catch (DatastoreException exp) { throw new EntityManagerException(exp); } }
java
static void validateDeferredIdAllocation(Object entity) { IdentifierMetadata identifierMetadata = EntityIntrospector.getIdentifierMetadata(entity); if (identifierMetadata.getDataType() == DataType.STRING) { throw new EntityManagerException( "Deferred ID allocation is not applicable for entities ...
java
public Mapper getMapper(Field field) { Type genericType = field.getGenericType(); Property propertyAnnotation = field.getAnnotation(Property.class); boolean indexed = true; if (propertyAnnotation != null) { indexed = propertyAnnotation.indexed(); } String cacheKey = computeCacheKey(generic...
java
private Mapper createMapper(Field field, boolean indexed) { lock.lock(); try { Mapper mapper; Class<?> fieldType = field.getType(); Type genericType = field.getGenericType(); String cacheKey = computeCacheKey(genericType, indexed); mapper = cache.get(cacheKey); if (mapper != ...
java
private static Credentials getCredentials(ConnectionParameters parameters) throws IOException { if (parameters.isEmulator()) { return NoCredentials.getInstance(); } InputStream jsonCredentialsStream = parameters.getJsonCredentialsStream(); if (jsonCredentialsStream != null) { return ServiceA...
java
private static HttpTransportOptions getHttpTransportOptions(ConnectionParameters parameters) { HttpTransportOptions.Builder httpOptionsBuilder = HttpTransportOptions.newBuilder(); httpOptionsBuilder.setConnectTimeout(parameters.getConnectionTimeout()); httpOptionsBuilder.setReadTimeout(parameters.getReadTim...
java
public static EntityMetadata introspect(Class<?> entityClass) { EntityMetadata cachedMetadata = cache.get(entityClass); if (cachedMetadata != null) { return cachedMetadata; } return loadMetadata(entityClass); }
java
private static EntityMetadata loadMetadata(Class<?> entityClass) { synchronized (entityClass) { EntityMetadata metadata = cache.get(entityClass); if (metadata == null) { EntityIntrospector introspector = new EntityIntrospector(entityClass); introspector.process(); metadata = intr...
java
private void process() { Entity entity = entityClass.getAnnotation(Entity.class); ProjectedEntity projectedEntity = entityClass.getAnnotation(ProjectedEntity.class); if (entity != null) { initEntityMetadata(entity); } else if (projectedEntity != null) { initEntityMetadata(projectedEntity); ...
java
private void processPropertyOverrides() { PropertyOverrides propertyOverrides = entityClass.getAnnotation(PropertyOverrides.class); if (propertyOverrides == null) { return; } PropertyOverride[] propertyOverridesArray = propertyOverrides.value(); for (PropertyOverride propertyOverride : propert...
java
private void processFields() { List<Field> fields = getAllFields(); for (Field field : fields) { if (field.isAnnotationPresent(Identifier.class)) { processIdentifierField(field); } else if (field.isAnnotationPresent(Key.class)) { processKeyField(field); } else if (field.isAnnot...
java
private List<Field> getAllFields() { List<Field> allFields = new ArrayList<>(); Class<?> clazz = entityClass; boolean stop; do { List<Field> fields = IntrospectionUtils.getPersistableFields(clazz); allFields.addAll(fields); clazz = clazz.getSuperclass(); stop = clazz == null || !...
java
private void processIdentifierField(Field field) { Identifier identifier = field.getAnnotation(Identifier.class); boolean autoGenerated = identifier.autoGenerated(); IdentifierMetadata identifierMetadata = new IdentifierMetadata(field, autoGenerated); entityMetadata.setIdentifierMetadata(identifierMetad...
java
private void processKeyField(Field field) { String fieldName = field.getName(); Class<?> type = field.getType(); if (!type.equals(DatastoreKey.class)) { String message = String.format("Invalid type, %s, for Key field %s in class %s. ", type, fieldName, entityClass); throw new EntityMan...
java
private void processParentKeyField(Field field) { String fieldName = field.getName(); Class<?> type = field.getType(); if (!type.equals(DatastoreKey.class)) { String message = String.format("Invalid type, %s, for ParentKey field %s in class %s. ", type, fieldName, entityClass); throw n...
java
private void processField(Field field) { PropertyMetadata propertyMetadata = IntrospectionUtils.getPropertyMetadata(field); if (propertyMetadata != null) { // If the field is from a super class, there might be some // overrides, so process those. if (!field.getDeclaringClass().equals(entityCla...
java
private void processVersionField(PropertyMetadata propertyMetadata) { Class<?> dataClass = propertyMetadata.getDeclaredType(); if (!long.class.equals(dataClass)) { String messageFormat = "Field %s in class %s must be of type %s"; throw new EntityManagerException(String.format(messageFormat, ...
java
private void validateAutoTimestampField(PropertyMetadata propertyMetadata) { Class<?> dataClass = propertyMetadata.getDeclaredType(); if (Collections.binarySearch(VALID_TIMESTAMP_TYPES, dataClass.getName()) < 0) { String messageFormat = "Field %s in class %s must be one of the following types - %s"; ...
java
private void applyPropertyOverride(PropertyMetadata propertyMetadata) { String name = propertyMetadata.getName(); Property override = entityMetadata.getPropertyOverride(name); if (override != null) { String mappedName = override.name(); if (mappedName != null && mappedName.trim().length() > 0) {...
java
private void processEmbeddedField(Field field) { // First create EmbeddedField so we can maintain the path/depth of the // embedded field EmbeddedField embeddedField = new EmbeddedField(field); // Introspect the embedded field. EmbeddedMetadata embeddedMetadata = EmbeddedIntrospector.introspect(embe...
java