From aaf4ccc69c36434da67e7ec646ed5cdf50dc13d8 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Tue, 28 Feb 2017 17:37:14 +0100 Subject: [PATCH] DATACMNS-999 - Improve resource extensive error message concatenation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We now use Assert.isTrue(…) taking a Supplier to avoid unnecessary String concatenation. Original pull request: #198. --- .../data/mapping/model/BasicPersistentEntity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java b/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java index 1d2e318ca..2de96fdc1 100644 --- a/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java +++ b/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 by the original author(s). + * Copyright 2011-2017 by the original author(s). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -420,9 +420,8 @@ public class BasicPersistentEntity> implement public PersistentPropertyAccessor getPropertyAccessor(Object bean) { Assert.notNull(bean, "Target bean must not be null!"); - Assert.isTrue(getType().isInstance(bean), - String.format(TYPE_MISMATCH, bean.getClass().getName(), getType().getName())); + () -> String.format(TYPE_MISMATCH, bean.getClass().getName(), getType().getName())); return propertyAccessorFactory.getPropertyAccessor(this, bean); } @@ -435,7 +434,8 @@ public class BasicPersistentEntity> implement public IdentifierAccessor getIdentifierAccessor(Object bean) { Assert.notNull(bean, "Target bean must not be null!"); - Assert.isTrue(getType().isInstance(bean), "Target bean is not of type of the persistent entity!"); + Assert.isTrue(getType().isInstance(bean), + () -> String.format(TYPE_MISMATCH, bean.getClass().getName(), getType().getName())); return hasIdProperty() ? new IdPropertyIdentifierAccessor(this, bean) : NullReturningIdentifierAccessor.INSTANCE; }