code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public OIdentifiableIterator<REC> setReuseSameRecord(final boolean reuseSameRecord) {
reusedRecord = (ORecordInternal<?>) (reuseSameRecord ? database.newInstance() : null);
return this;
} | java |
protected ORecordInternal<?> getRecord() {
final ORecordInternal<?> record;
if (reusedRecord != null) {
// REUSE THE SAME RECORD AFTER HAVING RESETTED IT
record = reusedRecord;
record.reset();
} else
record = null;
return record;
} | java |
protected ORecordInternal<?> readCurrentRecord(ORecordInternal<?> iRecord, final int iMovement) {
if (limit > -1 && browsedRecords >= limit)
// LIMIT REACHED
return null;
current.clusterPosition += iMovement;
if (iRecord != null) {
iRecord.setIdentity(current);
iRecord = lowLevelDatabase.lo... | java |
public void bindParameters(final Map<Object, Object> iArgs) {
if (parameterItems == null || iArgs == null || iArgs.size() == 0)
return;
for (Entry<Object, Object> entry : iArgs.entrySet()) {
if (entry.getKey() instanceof Integer)
parameterItems.get(((Integer) entry.getKey())).setValue... | java |
@Override
public boolean send(Context context, Report report) {
if (url != null) {
String reportStr = report.asJSON()
.toString();
try {
postReport(url, reportStr);
return true;
} catch (IOException e) {
... | java |
public static void post(URL url, String params) throws IOException {
URLConnection conn = url.openConnection();
if (conn instanceof HttpURLConnection) {
((HttpURLConnection) conn).setRequestMethod("POST");
conn.setRequestProperty("Content-Type" , "application/json");
}
... | java |
public static String read(InputStream in) throws IOException {
InputStreamReader isReader = new InputStreamReader(in, "UTF-8");
BufferedReader reader = new BufferedReader(isReader);
StringBuffer out = new StringBuffer();
char[] c = new char[4096];
for (int n; (n = reader.read(c))... | java |
public Object joinGame(long id, String password) {
return client.sendRpcAndWait(SERVICE, "joinGame", id, password);
} | java |
public Object observeGame(long id, String password) {
return client.sendRpcAndWait(SERVICE, "observeGame", id, password);
} | java |
public boolean switchToPlayer(long id, PlayerSide team) {
return client.sendRpcAndWait(SERVICE, "switchObserverToPlayer", id, team.id);
} | java |
protected byte[] serializeStreamValue(final int iIndex) throws IOException {
if (serializedValues[iIndex] <= 0) {
// NEW OR MODIFIED: MARSHALL CONTENT
OProfiler.getInstance().updateCounter("OMVRBTreeMapEntry.serializeValue", 1);
return ((OMVRBTreeMapProvider<K, V>) treeDataProvider).valueSeria... | java |
public MigrationJob[] retrieveJobs(int batchSize, int startIndex, JobType jobType)
throws IOException, LightblueException {
LOGGER.debug("Retrieving jobs: batchSize={}, startIndex={}", batchSize, startIndex);
DataFindRequest findRequest = new DataFindRequest("migrationJob", null);
... | java |
public ActiveExecution lock(String id)
throws Exception {
LOGGER.debug("locking {}", id);
if (!myLocks.contains(id)) {
if (locking.acquire(id, null)) {
myLocks.add(id);
ActiveExecution ae = new ActiveExecution();
ae.setMigrationJobI... | java |
public <H extends EventHandler> H getHandler(GwtEvent.Type<H> type, int index) {
return this.eventBus.superGetHandler(type, index);
} | java |
public <H extends EventHandler> void removeHandler(GwtEvent.Type<H> type, final H handler) {
this.eventBus.superDoRemove(type, null, handler);
} | java |
@Override
public void sendFailure(String message) {
System.out.print("Warning: " + message);
System.exit(1);
} | java |
@Override
public void sendError(String message) {
System.out.print("Critical: " + message);
System.exit(2);
} | java |
public Object execute(final Map<Object, Object> iArgs) {
if (className == null)
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
final ODatabaseRecord database = getDatabase();
if (database.getMetadata().getSchema().existsClass(className))
... | java |
public boolean callbackHooks(final TYPE iType, final OIdentifiable id) {
if (!OHookThreadLocal.INSTANCE.push(id))
return false;
try {
final ORecord<?> rec = id.getRecord();
if (rec == null)
return false;
boolean recordChanged = false;
for (ORecordHook hook : hoo... | java |
public String execute(String url, String urlParameters, String clientId, String secret, String method) throws
Exception {
HttpURLConnection connection;
String credentials = clientId + ":" + secret;
String authorizationHeader = "Basic " + Base64.getEncoder().encodeToString(credential... | java |
private void buildReport(Context context) {
try {
buildBaseReport();
buildApplicationData(context);
buildDeviceData(context);
buildLog();
report.put("application", app);
report.put("device", device);
report.put("log", logs);
... | java |
private void buildLog() throws JSONException {
logs = new JSONObject();
List<String> list = Log.getReportedEntries();
if (list != null) {
logs.put("numberOfEntry", list.size());
JSONArray array = new JSONArray();
for (String s : list) {
array.p... | java |
private void buildDeviceData(Context context) throws JSONException {
device = new JSONObject();
device.put("device", Build.DEVICE);
device.put("brand", Build.BRAND);
Object windowService = context.getSystemService(Context.WINDOW_SERVICE);
if (windowService instanceof WindowManag... | java |
private void buildApplicationData(Context context) throws JSONException {
app = new JSONObject();
app.put("package", context.getPackageName());
try {
PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
app.put("versionCode", info.ve... | java |
public Set<ODocument> getEdgesBetweenVertexes(final ODocument iVertex1, final ODocument iVertex2) {
return getEdgesBetweenVertexes(iVertex1, iVertex2, null, null);
} | java |
public Set<ODocument> getEdgesBetweenVertexes(final ODocument iVertex1, final ODocument iVertex2, final String[] iLabels) {
return getEdgesBetweenVertexes(iVertex1, iVertex2, iLabels, null);
} | java |
public Set<ODocument> getEdgesBetweenVertexes(final ODocument iVertex1, final ODocument iVertex2, final String[] iLabels,
final String[] iClassNames) {
final Set<ODocument> result = new HashSet<ODocument>();
if (iVertex1 != null && iVertex2 != null) {
// CHECK OUT EDGES
for (OIdentifi... | java |
public Set<OIdentifiable> getOutEdgesHavingProperties(final OIdentifiable iVertex, Iterable<String> iProperties) {
final ODocument vertex = iVertex.getRecord();
checkVertexClass(vertex);
return filterEdgesByProperties((OMVRBTreeRIDSet) vertex.field(VERTEX_FIELD_OUT), iProperties);
} | java |
public Set<OIdentifiable> getInEdgesHavingProperties(final OIdentifiable iVertex, Iterable<String> iProperties) {
final ODocument vertex = iVertex.getRecord();
checkVertexClass(vertex);
return filterEdgesByProperties((OMVRBTreeRIDSet) vertex.field(VERTEX_FIELD_IN), iProperties);
} | java |
public Set<OIdentifiable> getInEdgesHavingProperties(final ODocument iVertex, final Map<String, Object> iProperties) {
checkVertexClass(iVertex);
return filterEdgesByProperties((OMVRBTreeRIDSet) iVertex.field(VERTEX_FIELD_IN), iProperties);
} | java |
public synchronized OServerAdmin connect(final String iUserName, final String iUserPassword) throws IOException {
storage.createConnectionPool();
storage.setSessionId(-1);
try {
final OChannelBinaryClient network = storage.beginRequest(OChannelBinaryProtocol.REQUEST_CONNECT);
storage.se... | java |
@SuppressWarnings("unchecked")
public synchronized Map<String, String> listDatabases() throws IOException {
storage.checkConnection();
final ODocument result = new ODocument();
try {
final OChannelBinaryClient network = storage.beginRequest(OChannelBinaryProtocol.REQUEST_DB_LIST);
storag... | java |
public synchronized OServerAdmin createDatabase(final String iDatabaseType, String iStorageMode) throws IOException {
storage.checkConnection();
try {
if (storage.getName() == null || storage.getName().length() <= 0) {
OLogManager.instance().error(this, "Cannot create unnamed remote storage.... | java |
public synchronized boolean existsDatabase() throws IOException {
storage.checkConnection();
try {
final OChannelBinaryClient network = storage.beginRequest(OChannelBinaryProtocol.REQUEST_DB_EXIST);
try {
network.writeString(storage.getName());
} finally {
storage.endR... | java |
public synchronized OServerAdmin dropDatabase() throws IOException {
storage.checkConnection();
boolean retry = true;
while (retry)
try {
final OChannelBinaryClient network = storage.beginRequest(OChannelBinaryProtocol.REQUEST_DB_DROP);
try {
network.writeString(st... | java |
public ODocument clusterStatus() {
final ODocument response = sendRequest(OChannelBinaryProtocol.REQUEST_CLUSTER, new ODocument().field("operation", "status"),
"Cluster status");
OLogManager.instance().debug(this, "Cluster status %s", response.toJSON());
return response;
} | java |
public synchronized OServerAdmin replicationStop(final String iDatabaseName, final String iRemoteServer) throws IOException {
sendRequest(OChannelBinaryProtocol.REQUEST_REPLICATION, new ODocument().field("operation", "stop").field("node", iRemoteServer)
.field("db", iDatabaseName), "Stop replication");
... | java |
public synchronized ODocument getReplicationJournal(final String iDatabaseName, final String iRemoteServer) throws IOException {
OLogManager.instance().debug(this, "Retrieving the replication log for database '%s' from server '%s'...", iDatabaseName,
storage.getURL());
final ODocument response = se... | java |
public OServerAdmin replicationAlign(final String iDatabaseName, final String iRemoteServer, final String iOptions) {
OLogManager.instance().debug(this, "Started the alignment of database '%s' from server '%s' to '%s' with options %s",
iDatabaseName, storage.getURL(), iRemoteServer, iOptions);
send... | java |
public synchronized OServerAdmin copyDatabase(final String iDatabaseName, final String iDatabaseUserName,
final String iDatabaseUserPassword, final String iRemoteName, final String iRemoteEngine) throws IOException {
storage.checkConnection();
try {
final OChannelBinaryClient network = stora... | java |
public Object execute(final OIdentifiable o, final OCommandExecutor iRequester) {
// RESOLVE VALUES USING THE CURRENT RECORD
for (int i = 0; i < configuredParameters.length; ++i) {
if (configuredParameters[i] instanceof OSQLFilterItemField)
runtimeParameters[i] = ((OSQLFilterItemField) configu... | java |
public static EmbeddedJettyBuilder.ServletContextHandlerBuilder addWicketHandler(EmbeddedJettyBuilder embeddedJettyBuilder,
String contextPath,
EventL... | java |
public boolean add(final OIdentifiable e) {
if (e.getIdentity().isNew()) {
final ORecord<?> record = e.getRecord();
// ADD IN TEMP LIST
if (newItems == null)
newItems = new IdentityHashMap<ORecord<?>, Object>();
else if (newItems.containsKey(record))
return false;
newItems.put(record,... | java |
public int indexOf(final OIdentifiable iElement) {
if (delegate.isEmpty())
return -1;
final boolean prevConvert = delegate.isAutoConvertToRecord();
if (prevConvert)
delegate.setAutoConvertToRecord(false);
final int pos = Collections.binarySearch(delegate, iElement);
if (prevConvert)
// ... | java |
public ORDER compare(OQueryOperator other) {
final Class<?> thisClass = this.getClass();
final Class<?> otherClass = other.getClass();
int thisPosition = -1;
int otherPosition = -1;
for (int i = 0; i < DEFAULT_OPERATORS_ORDER.length; i++) {
// subclass of default operators inherit thei... | java |
public Object execute(final Map<Object, Object> iArgs) {
if (attribute == null)
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
final ODatabaseRecord database = getDatabase();
database.checkSecurity(ODatabaseSecurityResources.DATABASE, ORole... | java |
@Override
public boolean open() throws IOException {
lock.acquireExclusiveLock();
try {
// IGNORE IF IT'S SOFTLY CLOSED
super.open();
// CHECK FOR PENDING TRANSACTION ENTRIES TO RECOVER
recoverTransactions();
return true;
} finally {
lock.releaseExclus... | java |
public void addLog(final byte iOperation, final int iTxId, final int iClusterId, final long iClusterOffset,
final byte iRecordType, final int iRecordVersion, final byte[] iRecordContent, int dataSegmentId) throws IOException {
final int contentSize = iRecordContent != null ? iRecordContent.length : 0;
... | java |
private Set<Integer> scanForTransactionsToRecover() throws IOException {
// SCAN ALL THE FILE SEARCHING FOR THE TRANSACTIONS TO RECOVER
final Set<Integer> txToRecover = new HashSet<Integer>();
final Set<Integer> txToNotRecover = new HashSet<Integer>();
// BROWSE ALL THE ENTRIES
for (long of... | java |
private int recoverTransaction(final int iTxId) throws IOException {
int recordsRecovered = 0;
final ORecordId rid = new ORecordId();
final List<Long> txRecordPositions = new ArrayList<Long>();
// BROWSE ALL THE ENTRIES
for (long beginEntry = 0; eof(beginEntry); beginEntry = nextEntry(begin... | java |
public static String pingJdbcEndpoint(MuleContext muleContext, String muleJdbcDataSourceName, String tableName) {
DataSource ds = JdbcUtil.lookupDataSource(muleContext, muleJdbcDataSourceName);
Connection c = null;
Statement s = null;
ResultSet rs = null;
try {
c = ds.getConnection();
s = c.crea... | java |
public static String pingJmsEndpoint(MuleContext muleContext, String queueName) {
return pingJmsEndpoint(muleContext, DEFAULT_MULE_JMS_CONNECTOR, queueName);
} | java |
@SuppressWarnings("rawtypes")
private static boolean isQueueEmpty(MuleContext muleContext, String muleJmsConnectorName, String queueName) throws JMSException {
JmsConnector muleCon = (JmsConnector)MuleUtil.getSpringBean(muleContext, muleJmsConnectorName);
Session s = null;
QueueBrowser b = null;
... | java |
@Override
public T select(Object item) {
if (item == null) {
return null;
}
if (itemClass.isInstance(item)) {
return itemClass.cast(item);
}
logger.debug("item [{}] is not assignable to class [{}], returning null", item, itemClass);
return null;
} | java |
public BeanQuery<T> orderBy(String orderByProperty, Comparator propertyValueComparator) {
this.comparator = new DelegatedSortOrderableComparator(new PropertyComparator(orderByProperty,
propertyValueComparator));
return this;
} | java |
public BeanQuery<T> orderBy(Comparator... beanComparator) {
this.comparator = new DelegatedSortOrderableComparator(ComparatorUtils.chainedComparator(beanComparator));
return this;
} | java |
public T executeFrom(Object bean) {
List<T> executeFromCollectionResult = executeFrom(Collections.singleton(bean));
if (CollectionUtils.isEmpty(executeFromCollectionResult)) {
return null;
} else {
return executeFromCollectionResult.get(0);
}
} | java |
public List<T> execute() {
if (CollectionUtils.isEmpty(from)) {
logger.info("Querying from an empty collection, returning empty list.");
return Collections.emptyList();
}
List copied = new ArrayList(this.from);
logger.info("Start apply predicate [{}] to collection with [{}] items.", predic... | java |
public static BeanQuery<Map<String, Object>> select(KeyValueMapSelector... selectors) {
return new BeanQuery<Map<String, Object>>(new CompositeSelector(selectors));
} | java |
@Override
public void write(final Writer writer) throws ConfigurationException, IOException {
Preconditions.checkNotNull(writer);
@SuppressWarnings("unchecked") final
HashMap<String, Object> settings = (HashMap<String, Object>) fromNode(this.getModel().getInMemoryRepresentation());
... | java |
private ImmutableNode toNode(final Builder builder, final Object obj) {
assert !(obj instanceof List);
if (obj instanceof Map) {
return mapToNode(builder, (Map<String, Object>) obj);
} else {
return valueToNode(builder, obj);
}
} | java |
private ImmutableNode mapToNode(final Builder builder, final Map<String, Object> map) {
for (final Map.Entry<String, Object> entry : map.entrySet()) {
final String key = entry.getKey();
final Object value = entry.getValue();
if (value instanceof List) {
// For... | java |
private void addChildNode(final Builder builder, final String name, final Object value) {
assert !(value instanceof List);
final Builder childBuilder = new Builder();
// Set the name of the child node.
childBuilder.name(name);
// Set the value of the child node.
final Im... | java |
private ImmutableNode valueToNode(final Builder builder, final Object value) {
// Set the value of the node being built.
return builder.value(value).create();
} | java |
private Object fromNode(final ImmutableNode node) {
if (!node.getChildren().isEmpty()) {
final Map<String, List<ImmutableNode>> children = getChildrenWithName(node);
final HashMap<String, Object> map = new HashMap<>();
for (final Map.Entry<String, List<ImmutableNode>> entry ... | java |
public ClassSelector except(String... propertyNames) {
if(ArrayUtils.isEmpty(propertyNames)){
return this;
}
boolean updated = false;
for (String propertyToRemove : propertyNames) {
if (removePropertySelector(propertyToRemove)) {
updated = true;
}
}
if (updated) {
... | java |
public ClassSelector add(String... propertyNames) {
if (ArrayUtils.isNotEmpty(propertyNames)) {
for (String propertyNameToAdd : propertyNames) {
addPropertySelector(propertyNameToAdd);
}
}
return this;
} | java |
public ViewSelectionAttributeAssert attribute(String attributeName) {
isNotEmpty();
ViewSelectionAttribute attributeValues = new ViewSelectionAttribute(actual, attributeName);
return new ViewSelectionAttributeAssert(attributeValues);
} | java |
private static Message generateHeader(HeaderValues param) {
HeaderFields header = new HeaderFields();
setValues(header, param);
Message headerMsg = header.unwrap();
for (String comment : param.comments) {
headerMsg.addComment(comment);
}
return headerMsg;
... | java |
public ViewSelection selectViews(View view) {
ViewSelection result = new ViewSelection();
for (List<Selector> selectorParts : selectorGroups) {
result.addAll(selectViewsForGroup(selectorParts, view));
}
return result;
} | java |
@Override
public int compareTo(final Problem o) {
final int ix = this.severity.ordinal();
final int oid = o.severity.ordinal();
return ix - oid;
} | java |
public static String fixValue(String value) {
if (value != null && !value.equals("")) {
final String[] words = value.toLowerCase().split("_");
value = "";
for (final String word : words) {
if (word.length() > 1) {
value += word.substring(0, 1).toUpperCase() + word.substring(1) + " ";
} el... | java |
public static String removeLast(String original, String string) {
int lastIndexOf = original.lastIndexOf(string);
if (lastIndexOf == -1) {
return original;
}
return original.substring(0, lastIndexOf);
} | java |
public static String getFirstLine(final String message) {
if (isEmpty(message)) {
return message;
}
if (message.contains("\n")) {
return message.split("\n")[0];
}
return message;
} | java |
public static void copyToClipboard(String text) {
final StringSelection stringSelection = new StringSelection(text);
final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, stringSelection);
} | java |
public String toQueryString() {
final StringBuffer buf = new StringBuffer();
final Object value1 = this.values.get(0);
buf.append(this.column.getName());
switch (this.type) {
case STARTS_WIDTH:
buf.append(" like '" + value1 + "%'");
break;
case CONTAINS:
buf.append(" like '%" + value1 + "%... | java |
public static String getNaturalAnalogueSequence(PolymerNotation polymer) throws HELM2HandledException, PeptideUtilsException, ChemistryException {
checkPeptidePolymer(polymer);
return FastaFormat.generateFastaFromPeptide(MethodsMonomerUtils.getListOfHandledMonomers(polymer.getListMonomers()));
} | java |
public static String getSequence(PolymerNotation polymer) throws HELM2HandledException, PeptideUtilsException, ChemistryException{
checkPeptidePolymer(polymer);
StringBuilder sb = new StringBuilder();
List<Monomer> monomers = MethodsMonomerUtils.getListOfHandledMonomers(polymer.getListMonomers());
... | java |
private static void processOtherMappings() {
codeToJavaMapping.clear();
codeToJKTypeMapping.clear();
shortListOfJKTypes.clear();
Set<Class<?>> keySet = javaToCodeMapping.keySet();
for (Class<?> clas : keySet) {
List<Integer> codes = javaToCodeMapping.get(clas);
for (Integer code : codes) {
c... | java |
protected void loadDefaultConfigurations() {
if (JK.getURL(DEFAULT_LABLES_FILE_NAME) != null) {
logger.debug("Load default lables from : " + DEFAULT_LABLES_FILE_NAME);
addLables(JKIOUtil.readPropertiesFile(DEFAULT_LABLES_FILE_NAME));
}
} | java |
public static <T> T cloneBean(final Object bean) {
try {
return (T) BeanUtils.cloneBean(bean);
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
} | java |
public static Class<?> getClass(final String beanClassName) {
try {
return Class.forName(beanClassName);
} catch (final ClassNotFoundException e) {
throw new RuntimeException(e);
}
} | java |
public static <T> T getPropertyValue(final Object instance, final String fieldName) {
try {
return (T) PropertyUtils.getProperty(instance, fieldName);
} catch (final Exception e) {
throw new RuntimeException(e);
}
} | java |
public static boolean isBoolean(final Class type) {
if (Boolean.class.isAssignableFrom(type)) {
return true;
}
return type.getName().equals("boolean");
} | java |
public static void setPeopertyValue(final Object target, final String fieldName, Object value) {
JK.logger.trace("setPeopertyValue On class({}) on field ({}) with value ({})", target, fieldName, value);
try {
if (value != null) {
Field field = getFieldByName(target.getClass(), fieldName);
if (field.... | java |
public static void addItemToList(final Object target, final String fieldName, final Object value) {
try {
List list = (List) getFieldValue(target, fieldName);
list.add(value);
} catch (Exception e) {
throw new RuntimeException(e);
}
} | java |
public static Class<?> toClass(final String name) {
try {
return Class.forName(name);
} catch (final ClassNotFoundException e) {
throw new RuntimeException(e);
}
} | java |
public static Class<?>[] toClassesFromObjects(final Object[] params) {
final Class<?>[] classes = new Class<?>[params.length];
int i = 0;
for (final Object object : params) {
if (object != null) {
classes[i++] = object.getClass();
} else {
classes[i++] = Object.class;
}
}
return cla... | java |
public static boolean isMethodDirectlyExists(Object object, String methodName, Class<?>... params) {
try {
Method method = object.getClass().getDeclaredMethod(methodName, params);
return true;
} catch (NoSuchMethodException e) {
return false;
} catch (SecurityException e) {
throw new RuntimeExc... | java |
public static Object toObject(final String xml) {
// XStream x = createXStream();
// return x.fromXML(xml);
// try {
final ByteArrayInputStream out = new ByteArrayInputStream(xml.getBytes());
final XMLDecoder encoder = new XMLDecoder(out);
final Object object = encoder.readObject();
//
encoder.c... | java |
public static <T> Class<? extends T> getGenericParamter(String handler) {
ParameterizedType parameterizedType = (ParameterizedType) JKObjectUtil.getClass(handler).getGenericInterfaces()[0];
Class<? extends T> clas = (Class<? extends T>) (parameterizedType.getActualTypeArguments()[0]);
return clas;
} | java |
public static boolean isClassAvilableInClassPath(String string) {
try {
Class.forName(string);
return true;
} catch (ClassNotFoundException e) {
return false;
}
} | java |
public static <T> String getInstanceVariables(Class<T> clas) {
StringBuffer fieldsString = new StringBuffer();
Field[] fields = clas.getDeclaredFields();
int i = 0;
for (Field field : fields) {
if (i++ > 0) {
fieldsString.append(JK.CSV_SEPARATOR);
}
fieldsString.append(field.getName());
... | java |
public static String toJson(Object obj) {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writeValueAsString(obj);
} catch (IOException e) {
JK.throww(e);
return null;
}
} | java |
public static <T> Object jsonToObject(String json, Class<T> clas) {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.readValue(json, clas);
} catch (IOException e) {
JK.throww(e);
return null;
}
} | java |
public static String getFieldNameByType(Class<?> classType, Class<?> fieldType) {
Field[] declaredFields = classType.getDeclaredFields();
for (Field field : declaredFields) {
if (field.getType().isAssignableFrom(fieldType)) {
return field.getName();
}
}
if (classType.getSuperclass() != null) {
... | java |
public static boolean isFieldExists(Class<?> clas, String fieldName) {
Field[] fields = clas.getDeclaredFields();
for (Field field : fields) {
if (field.getName().equals(fieldName)) {
return true;
}
}
if (clas.getSuperclass() != null) {
return isFieldExists(clas.getSuperclass(), fieldName);... | java |
public static List<String> getAllClassesInPackage(String packageName) {
List<String> classesNames = new Vector<>();
// create scanner and disable default filters (that is the 'false' argument)
final ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
... | java |
public static List<Field> getAllFields(Class<?> clas) {
JK.fixMe("add caching..");
List<Field> list = new Vector<>();
// start by fields from the super class
if (clas.getSuperclass() != null) {
list.addAll(getAllFields(clas.getSuperclass()));
}
Field[] fields = clas.getDeclaredFields();
for (Fi... | java |
public static <T> T createInstanceForGenericClass(Object parent) {
try {
Object instance = getGenericClassFromParent(parent).newInstance();
return (T) instance;
} catch (InstantiationException | IllegalAccessException e) {
JK.throww(e);
}
return null;
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.