• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Predicate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.db4o.query.Predicate的典型用法代码示例。如果您正苦于以下问题:Java Predicate类的具体用法?Java Predicate怎么用?Java Predicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Predicate类属于com.db4o.query包,在下文中一共展示了Predicate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: checkRegIdUsed

import com.db4o.query.Predicate; //导入依赖的package包/类
public static boolean checkRegIdUsed(final String idGenerated) {

        //openDb4o();
        List<RegisterContextRequest> results;
        //final String updateRegId = rcrNew.getRegistrationId();
        results = db.query(new Predicate<RegisterContextRequest>() {
            public boolean match(RegisterContextRequest req) {
                String storedRegID = req.getRegistrationId();
                if (storedRegID.equals(idGenerated)) {
                    return true;
                }
                return false;
            }
        });

        if (results.size() > 0) {
            // closeDb4o();
            return true;
        }
        //closeDb4o();
        return false;
    }
 
开发者ID:UniSurreyIoT,项目名称:fiware-iot-discovery-ngsi9,代码行数:23,代码来源:RegisterStoreAccess.java


示例2: deleteRegistration

import com.db4o.query.Predicate; //导入依赖的package包/类
public static boolean deleteRegistration(final RegisterContextRequest rcrNew) {

        List<RegisterContextRequest> results;
        final String updateRegId = rcrNew.getRegistrationId();

        results = db.query(new Predicate<RegisterContextRequest>() {
            public boolean match(RegisterContextRequest req) {
                String storedRegID = req.getRegistrationId();
                if (storedRegID.equals(updateRegId)) {
                    return true;
                }
                return false;
            }
        });

        if (results.size() > 0) {
            RegisterContextRequest found = results.get(0);
            System.out.println("Deleting registration");
            db.delete(found);
            db.commit();
            return true;
        }
        return false;
    }
 
开发者ID:UniSurreyIoT,项目名称:fiware-iot-discovery-ngsi9,代码行数:25,代码来源:RegisterStoreAccess.java


示例3: deleteSubscription

import com.db4o.query.Predicate; //导入依赖的package包/类
public static boolean deleteSubscription(final String subsID) {
    List<SubscribeContextAvailabilityRequest> results;
    //final String updateSubId = rcrNew.getSubscriptionId();
    results = db.query(new Predicate<SubscribeContextAvailabilityRequest>() {
        public boolean match(SubscribeContextAvailabilityRequest req) {
            String storedRegID = req.getSubscriptionId();
            return storedRegID.equals(subsID);
        }
    });
    if (results.size() > 0) {
        SubscribeContextAvailabilityRequest found = results.get(0);
        System.out.println("Deleting SubscribeContextAvailabilityRequest");
        //found.getReference();
        db.delete(found);
        db.commit();
        return true;
    }
    return false;
}
 
开发者ID:UniSurreyIoT,项目名称:fiware-iot-discovery-ngsi9,代码行数:20,代码来源:SubscriptionStoreAccess.java


示例4: checkSubIdUsed

import com.db4o.query.Predicate; //导入依赖的package包/类
public static boolean checkSubIdUsed(final String idGenerated) {

        //openDb4o();
        List<SubscribeContextAvailabilityRequest> results;
        //final String updateRegId = rcrNew.getRegistrationId();
        results = db.query(new Predicate<SubscribeContextAvailabilityRequest>() {
            public boolean match(SubscribeContextAvailabilityRequest req) {
                String storedRegID = req.getSubscriptionId();
                if (storedRegID.equals(idGenerated)) {
                    return true;
                }
                return false;
            }
        });

        if (results.size() > 0) {
            // closeDb4o();
            return true;
        }
        //closeDb4o();
        return false;
    }
 
开发者ID:UniSurreyIoT,项目名称:fiware-iot-discovery-ngsi9,代码行数:23,代码来源:SubscriptionStoreAccess.java


示例5: deleteExpiredRegistrations

import com.db4o.query.Predicate; //导入依赖的package包/类
public boolean deleteExpiredRegistrations() {

        List<RegisterContextRequest> results;

        results = RegisterStoreAccess.db.query(new Predicate<RegisterContextRequest>() {
            @Override
            public boolean match(RegisterContextRequest req) {
                Instant timestamp = req.getTimestamp();
                Duration duration = Duration.parse(req.getDuration());
                Instant expiry = timestamp.plus(duration);
                Instant now = Instant.now();
                boolean expired = now.isAfter(expiry);
                //if timestamp + duration isAfter time now
                return expired;
            }
        });
        if (results.size() > 0) {
            for (RegisterContextRequest found : results) {
                System.out.println("Deleting expired registration");
                RegisterStoreAccess.db.delete(found);
                RegisterStoreAccess.db.commit();
            }

            return true;
        }
        return false;
    }
 
开发者ID:UniSurreyIoT,项目名称:fiware-iot-discovery-ngsi9,代码行数:28,代码来源:ExpirationScanner.java


示例6: deleteExpiredSubscriptions

import com.db4o.query.Predicate; //导入依赖的package包/类
public boolean deleteExpiredSubscriptions() {

        List<SubscribeContextAvailabilityRequest> results;

        results = SubscriptionStoreAccess.db.query(new Predicate<SubscribeContextAvailabilityRequest>() {
            @Override
            public boolean match(SubscribeContextAvailabilityRequest req) {
                Instant timestamp = req.getTimestamp();
                Duration duration = Duration.parse(req.getDuration());
                Instant expiry = timestamp.plus(duration);
                Instant now = Instant.now();
                boolean expired = now.isAfter(expiry);
                //if timestamp + duration isAfter time now
                return expired;
            }
        });

        if (results.size() > 0) {
            for (SubscribeContextAvailabilityRequest found : results) {
                System.out.println("Deleting expired registration");
                SubscriptionStoreAccess.db.delete(found);
                SubscriptionStoreAccess.db.commit();
            }
            return true;
        }
        return false;
    }
 
开发者ID:UniSurreyIoT,项目名称:fiware-iot-discovery-ngsi9,代码行数:28,代码来源:ExpirationScanner.java


示例7: getRegByEntityType

import com.db4o.query.Predicate; //导入依赖的package包/类
static public List<RegisterContextRequest> getRegByEntityType(
            final String entityType) {

        System.out.println("get by type: "+ entityType);
        List<RegisterContextRequest> results;

        results = db.query(new Predicate<RegisterContextRequest>() {
            public boolean match(RegisterContextRequest req) {

                final int contRegListSize = req
                        .getContextRegistration().size();
//                System.out.println("contRegListSize: " + contRegListSize);
                for (int i = 0; i < contRegListSize; i++) {

                    final int entityIdListSize = req
                            .getContextRegistration().get(i)
                            .getEntityId().size();
//                    System.out.println("entityidListSize: " + entityIdListSize);

                    for (int j = 0; j < entityIdListSize; j++) {

                        String storedEType = req
                                .getContextRegistration().get(i)
                                .getEntityId().get(j)
                                .getType();

                        //return storedEType.equals(entityType);
                        if (storedEType.equals(entityType)) {
                            return true;
                        }
                    }
                }//contRegList loop
                return false;
            }
        });
        System.out.println("size of \"type\" result:" + results.size());
        return results;
    }
 
开发者ID:UniSurreyIoT,项目名称:fiware-iot-discovery-ngsi9,代码行数:39,代码来源:RegisterStoreAccess.java


示例8: updateSubscription

import com.db4o.query.Predicate; //导入依赖的package包/类
public static boolean updateSubscription(final UpdateContextAvailabilitySubscriptionRequest updSubReq) {
    List<SubscribeContextAvailabilityRequest> results;
    //final String updateSubId = rcrNew.getSubscriptionId();
    results = db.query(new Predicate<SubscribeContextAvailabilityRequest>() {
        public boolean match(SubscribeContextAvailabilityRequest req) {
            String storedRegID = req.getSubscriptionId();
            return storedRegID.equals(updSubReq.getSubscriptionId());
        }
    });
    if (results.size() > 0) {
        SubscribeContextAvailabilityRequest subReqFound = results.get(0);
        System.out.println("Updating SubscribeContextAvailabilityRequest");

        subReqFound.getEntityId().clear();
        subReqFound.getEntityId().addAll(updSubReq.getEntityId());
        subReqFound.getAttribute().clear();
        subReqFound.getAttribute().addAll(updSubReq.getAttribute());
        subReqFound.setRestriction(updSubReq.getRestriction());
        subReqFound.setDuration(updSubReq.getDuration());

        try {
            db.store(subReqFound);
            db.commit();
        } finally {
            System.out.println("Stored SubscribeContextAvailabilityRequest: " + subReqFound.getSubscriptionId());
        }
        return true;
    }
    return false;
}
 
开发者ID:UniSurreyIoT,项目名称:fiware-iot-discovery-ngsi9,代码行数:31,代码来源:SubscriptionStoreAccess.java


示例9: getKeys

import com.db4o.query.Predicate; //导入依赖的package包/类
@Override
public Collection<Integer> getKeys() throws StorageOperationException {
	ObjectContainer db = Db4oEmbedded.openFile(getConfiguration(), source);

	final Collection<Integer> result = new ArrayList<Integer>();

	try {
		db.query(new Predicate<V>() {
			@Override
			public boolean match(V v) {
				result.add(v.hashCode());
				return false;
			}
		});

	} finally {
		db.close();
	}

	return result;
}
 
开发者ID:kboom,项目名称:setphrase,代码行数:22,代码来源:DB4oObjectStorage.java


示例10: getAll

import com.db4o.query.Predicate; //导入依赖的package包/类
@Override
public List<V> getAll(final K... keys) throws StorageOperationException {
	ObjectContainer db = Db4oEmbedded.openFile(getConfiguration(), source);

	List<V> result = null;
	try {
		result = db.query(new Predicate<V>() {
			@Override
			public boolean match(V v) {
				for (K key : keys) {
					if (key.match(v))
						return true;
				}
				return false;
			}
		});

	} finally {
		db.close();
	}
	if (result == null)
		return createList();
	else
		return result;
}
 
开发者ID:kboom,项目名称:setphrase,代码行数:26,代码来源:DB4oObjectStorage.java


示例11: put

import com.db4o.query.Predicate; //导入依赖的package包/类
@Override
public void put(final K key, V value) throws StorageOperationException {
	ObjectContainer db = Db4oEmbedded.openFile(getConfiguration(), source);
	ObjectSet<V> set = db.query(new Predicate<V>() {
		@Override
		public boolean match(V v) {
			if (key.match(v))
				return true;
			else
				return false;
		}
	});
	db.delete(set);
	db.store(value);
	db.close();
}
 
开发者ID:kboom,项目名称:setphrase,代码行数:17,代码来源:DB4oObjectStorage.java


示例12: read

import com.db4o.query.Predicate; //导入依赖的package包/类
public ITransazione read(final Integer id)
{
    ObjectContainer client = DbManagerSingleton.getInstance().getClient();
    List<TransazioneSmartProxy> result = client.query(new Predicate<TransazioneSmartProxy>() {
        @Override
        public boolean match(TransazioneSmartProxy candidate) {
            Integer idTrans;
            try {
                idTrans = candidate.getId();
            }
            catch (RemoteException ex) {
                return false;
            }
            if(idTrans.intValue() == id.intValue())
                return true;
            else
                return false;
        }
    });
    if(result.isEmpty())
        return null;
    ITransazione trans = result.get(0);
    return trans;
}
 
开发者ID:GameShopAdvance,项目名称:GameShop-Advance,代码行数:25,代码来源:DbVenditaSingleton.java


示例13: read

import com.db4o.query.Predicate; //导入依赖的package包/类
public IDescrizioneProdotto read(final IDProdotto code) {
     ObjectContainer client = DbManagerSingleton.getInstance().getClient();
     List<DescrizioneProdottoSmartProxy> result = client.query(new Predicate<DescrizioneProdottoSmartProxy>() {
         @Override
         public boolean match(DescrizioneProdottoSmartProxy candidate) {
            IDProdotto codice;
            try {
                codice = candidate.getCodiceProdotto();
            }
            catch (RemoteException ex) {
                return false;
            }
            if(codice.getCodice().equals(code.getCodice()))
                return true;
            else
                return false;
        }
    });
    if(result.isEmpty())
        return null;
    IDescrizioneProdotto desc = result.get(0);
    client.ext().refresh(desc, 10);
    return desc;  
}
 
开发者ID:GameShopAdvance,项目名称:GameShop-Advance,代码行数:25,代码来源:DbDescrizioneProdottoSingleton.java


示例14: readBelowThreshold

import com.db4o.query.Predicate; //导入依赖的package包/类
/**
 * Restituisce gli oggetti DescrizioneProdotto che si trovano al di sotto della soglia stabilita
 * @return Lista delle descrizioni sotto soglia
 */
public LinkedList<IDescrizioneProdotto> readBelowThreshold(){
    ObjectContainer client = DbManagerSingleton.getInstance().getClient();
    ObjectSet<IDescrizioneProdotto> result = client.query(new Predicate<IDescrizioneProdotto>() {

        @Override
        public boolean match(IDescrizioneProdotto candidate) {
            if(candidate.getClass() != DescrizioneProdottoSmartProxy.class)
                return false;
            else
               return candidate.sottoSoglia();
        }
    });
    if(result.isEmpty())
       return new ActivatableLinkedList<>();
    else{
        LinkedList<IDescrizioneProdotto> list = new ActivatableLinkedList<>(result);
        return list;
    }
}
 
开发者ID:GameShopAdvance,项目名称:GameShop-Advance,代码行数:24,代码来源:DbDescrizioneProdottoSingleton.java


示例15: read

import com.db4o.query.Predicate; //导入依赖的package包/类
public IPrenotazione read(final Integer id)
 {
    ObjectContainer client = DbManagerSingleton.getInstance().getClient();
    ObjectSet<PrenotazioneSmartProxy> result = client.query(new Predicate<PrenotazioneSmartProxy>() {
        @Override
        public boolean match(PrenotazioneSmartProxy candidate) {
            Integer idTrans;
            try {
                idTrans = candidate.getId();
            }
            catch (RemoteException ex) {
                return false;
            }
            if(idTrans.intValue() == id.intValue())
                return true;
            else
                return false;
        }
    });
    if(result.isEmpty())
        return null;
    return (IPrenotazione) result.get(0);
}
 
开发者ID:GameShopAdvance,项目名称:GameShop-Advance,代码行数:24,代码来源:DbPrenotazioneSingleton.java


示例16: getSessionsByCategory

import com.db4o.query.Predicate; //导入依赖的package包/类
public List<Session> getSessionsByCategory(final String categorie) {
	List<Session> list = new ArrayList<Session>();
	list = db().query(new Predicate<Session>() {
		@Override
		public boolean match(Session test) {
			return Arrays.asList(test.getCategory()).contains(categorie);
		}
	});
	return list;

}
 
开发者ID:JCERTIFLab,项目名称:jcertif-android-2013,代码行数:12,代码来源:SessionProvider.java


示例17: delete

import com.db4o.query.Predicate; //导入依赖的package包/类
@Override
public void delete(ScriptableObject obj, String type) {
    //TODO delete by _id_
    ObjectContainer con = getDB(type);

    final HashMap<Object, Object> map = new HashMap<>();
    for (Object id : obj.getAllIds()) {
        map.put(id, obj.get(id));
    }
    ObjectSet<HashMap<Object, Object>> maps = con.query(new Predicate<HashMap<Object, Object>>() {
        @Override
        public boolean match(HashMap<Object, Object> et) {
            for (Object key : map.keySet()) {
                if (!(et.containsKey(key) && et.get(key).equals(map.get(key)))) {
                    return false;
                }
            }
            return true;
        }
    });
    while (maps.hasNext()) {
        con.delete(maps.next());
    }
    con.commit();
}
 
开发者ID:govu,项目名称:govu,代码行数:26,代码来源:DB4OProvider.java


示例18: get

import com.db4o.query.Predicate; //导入依赖的package包/类
public T get(final Object id) {

		T result = null;

		synchronized (DB4OUtils.class) {

			ObjectContainer oc = Db4oEmbedded.openFile(DB4OUtils
					.getDataBasePath());

			try {
				ObjectSet<T> os = oc.query(new Predicate<T>() {

					/**
				 * 
				 */
					private static final long serialVersionUID = 7212666772385276584L;

					@Override
					public boolean match(T t) {
						// TODO Auto-generated method stub
						return t.getId() != null && t.getId().equals(id);
					}
				});

				if (os.size() > 0) {
					result = os.get(0);
				}
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			} finally {

				oc.close();
			}
		}

		return result;
	}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:39,代码来源:BaseProvider.java


示例19: saveOrUpdateAll

import com.db4o.query.Predicate; //导入依赖的package包/类
public void saveOrUpdateAll(Collection<T> col, final Match<T> match)
		throws Exception {
	if (col == null || col.size() == 0) {
		return;
	}

	synchronized (DB4OUtils.class) {

		ObjectContainer oc = Db4oEmbedded.openFile(DB4OUtils
				.getDataBasePath());

		try {
			for (final T obj : col) {

				ObjectSet<T> os = oc.query(new Predicate<T>() {

					/**
				 * 
				 */
					private static final long serialVersionUID = 2793555621552211152L;

					@Override
					public boolean match(T t) {
						// TODO Auto-generated method stub
						return match.match(t, obj);
					}
				});

				if (os.size() > 0) {
					T old = os.get(0);
					DB4OUtils.copyFields(obj, old);

					oc.store(old);

				} else {
					oc.store(obj);
				}
				
			}

			oc.commit();
		} catch (Exception e) {
			oc.rollback();
			throw e;

		} finally {

			oc.close();
		}

	}
}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:53,代码来源:BaseProvider.java


示例20: saveOrUpdate

import com.db4o.query.Predicate; //导入依赖的package包/类
public void saveOrUpdate(final T obj, final Match<T> match) {
	if (obj == null) {
		return;
	}

	synchronized (DB4OUtils.class) {

		ObjectContainer oc = Db4oEmbedded.openFile(DB4OUtils
				.getDataBasePath());
		try {

			ObjectSet<T> os = oc.query(new Predicate<T>() {

				/**
			 * 
			 */
				private static final long serialVersionUID = 2793555621552211152L;

				@Override
				public boolean match(T t) {
					// TODO Auto-generated method stub
					return match.match(t, obj);
				}
			});

			if (os.size() > 0) {
				T old = os.get(0);
				DB4OUtils.copyFields(obj, old);

				oc.store(old);

			} else {
				
				oc.store(obj);
			}
			
			oc.commit();

		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			
			oc.close();
		}
	}
}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:48,代码来源:BaseProvider.java



注:本文中的com.db4o.query.Predicate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Converters类代码示例发布时间:2022-05-22
下一篇:
Java ShearingGraphMousePlugin类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap