List of usage examples for org.springframework.util Assert notNull
@Deprecated public static void notNull(@Nullable Object object)
From source file:com.iterzp.momo.utils.JsonUtils.java
/** * JSON?// www .j a v a 2 s . c om * * @param json * JSON * @param valueType * * @return */ public static <T> T toObject(String json, Class<T> valueType) { Assert.hasText(json); Assert.notNull(valueType); try { return mapper.readValue(json, valueType); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.audi.interview.booking.service.VehicleService.java
public Vehicle saveVehicle(Vehicle vehicle) { Assert.notNull(vehicle); Assert.notNull(vehicle.getColor());/* ww w. j a v a 2 s.c om*/ Assert.notNull(vehicle.getLicensePlate()); Assert.notNull(vehicle.getModel()); Assert.notNull(vehicle.getValidTill()); // date not in the past Assert.isTrue(vehicle.getValidTill().after(new Date()), "field validTill should be at least a future date"); Assert.notNull(vehicle.getVin()); return vehicleRepository.saveAndFlush(vehicle); }
From source file:egov.data.hibernate.repository.support.HibernateEntityInformationSupport.java
public static <T> HibernateEntityInformation<T, ?> getMetadata(Class<T> domainClass, SessionFactory sessionFactory) { Assert.notNull(domainClass); Assert.notNull(sessionFactory);//from w w w .j av a 2 s . c o m ClassMetadata metadata = sessionFactory.getClassMetadata(domainClass); if (Persistable.class.isAssignableFrom(domainClass)) { return new HibernatePersistableEntityInformation(domainClass, metadata); } else { return new HibernateMetamodelEntityInformation(domainClass, metadata); } }
From source file:it.inserpio.mapillary.gopro.importer.parser.bikematepro.transformer.BikeMateProGPXTransformer.java
public static List<GPXDateTimePoint> translate(BikeMateProGPX bikeMateProGPX) throws ParseException { List<GPXDateTimePoint> result = null; Assert.notNull(bikeMateProGPX); Assert.notNull(bikeMateProGPX.getTrk()); if (CollectionUtils.isNotEmpty(bikeMateProGPX.getTrk().getTrksegs())) { for (BikeMateProTRKSEG bikeMateProTRKSEG : bikeMateProGPX.getTrk().getTrksegs()) { result = new ArrayList<GPXDateTimePoint>(); for (BikeMateProTRKPT bikeMateProTRKPT : bikeMateProTRKSEG.getTrkpts()) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); Date date = dateFormat.parse(bikeMateProTRKPT.getTime()); result.add(new GPXDateTimePoint(bikeMateProTRKPT.getLon(), bikeMateProTRKPT.getLat(), date.getTime())); }//from ww w .ja va2 s . c o m } } return result; }
From source file:biz.c24.io.spring.config.BeanDefinitionUtils.java
/** * Returns the {@link AbstractBeanDefinition} built by the given builder applying the given source to it. The actual * source will be extracted using the given {@link ParserContext}. * /* w w w . j av a2 s . c o m*/ * @param builder * @param source * @param context * @return */ public static AbstractBeanDefinition getSourcedBeanDefinition(BeanDefinitionBuilder builder, Object source, ParserContext context) { Assert.notNull(builder); Assert.notNull(source); Assert.notNull(context); AbstractBeanDefinition definition = builder.getBeanDefinition(); definition.setSource(context.extractSource(source)); return definition; }
From source file:org.jcf.JCFFactory.java
/** * created new instance of JCFMultiUserChat * @param jCFConnection the former created insance of a connection object * @return ins<tance of JCFMultiUserChat *//*from w w w . j av a 2 s.c o m*/ public static JCFMultiUserChat newJCFMultiUserChat(JCFConnection jCFConnection) { Assert.notNull(jCFConnection); return new MultiUserChatImpl(jCFConnection); }
From source file:org.nebulaframework.util.hashing.SHA1Generator.java
/** * Generates SHA1 Hash for the given {@code byte[]} and returns * the hash code as a {@code byte[]}.// ww w. jav a 2 s . c o m * * @param source source value * @return SHA-1 hash for value * * @see #generate(String) * @see #generateAsString(byte[]) * * @throws IllegalArgumentException if {@code source} is {@code null} */ public static byte[] generate(byte[] source) throws IllegalArgumentException { // Check for nulls Assert.notNull(source); try { MessageDigest digest = MessageDigest.getInstance("SHA"); digest.update(source); return digest.digest(); } catch (NoSuchAlgorithmException e) { log.fatal("Cannot load hashing algorithm", e); throw new RuntimeException(e); } }
From source file:converters.VoteToStringConverter.java
@Override public String convert(Vote vote) { Assert.notNull(vote); String result; result = String.valueOf(vote.getId()); return result; }
From source file:converters.VotationToStringConverter.java
@Override public String convert(Votation votation) { Assert.notNull(votation); String result; result = String.valueOf(votation.getId()); return result; }
From source file:net.shopxx.util.JsonUtil.java
/** * ?JSON?// w w w . j ava 2 s. c o m * @param response HttpServletResponse * @param object */ public static void toJson(HttpServletResponse response, Object value) { Assert.notNull(response); Assert.notNull(value); try { mapper.writeValue(response.getWriter(), value); } catch (Exception e) { e.printStackTrace(); } }