General code cleanup

This commit is contained in:
Oleg Zhurakousky
2018-06-25 23:03:50 -04:00
parent ed228dae59
commit d8b1b7036b
6 changed files with 18 additions and 72 deletions

View File

@@ -1,44 +0,0 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.stream.binder;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.expression.Expression;
/**
* JSON serializer for Expression value.
*
* @author Ilayaperumal Gopinathan
*/
public class ExpressionSerializer extends JsonSerializer<Expression> {
public ExpressionSerializer() {
}
@Override
public void serialize(Expression expression, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
throws IOException {
if (expression != null) {
jsonGenerator.writeString(expression.getExpressionString());
}
}
}

View File

@@ -69,26 +69,4 @@ public abstract class JavaClassMimeTypeUtils {
}
return mimeType;
}
/**
* Retrieve the class name from the type parameter in {@link MimeType}.
*
* @param mimeType {@link MimeType} to retrieve class name from
* @return class name from the type parameter in MimeType and null if the class name cannot be determined
*/
public static String classNameFromMimeType(MimeType mimeType) {
Assert.notNull(mimeType, "mimeType cannot be null.");
String className = mimeType.getParameter("type");
if (className == null) {
return null;
}
// unwrap quotes if any
className = className.replace("\"", "");
// restore trailing ';'
if (className.contains("[L")) {
className += ";";
}
return className;
}
}

View File

@@ -16,11 +16,16 @@
package org.springframework.cloud.stream.binder;
import java.io.IOException;
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.Min;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.cloud.stream.config.MergableProperties;
@@ -189,4 +194,14 @@ public class ProducerProperties implements MergableProperties {
this.partitionSelectorName = partitionSelectorName;
}
static class ExpressionSerializer extends JsonSerializer<Expression> {
@Override
public void serialize(Expression expression, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
throws IOException {
if (expression != null) {
jsonGenerator.writeString(expression.getExpressionString());
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 the original author or authors.
* Copyright 2016-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,8 +29,6 @@ import org.springframework.core.convert.ConversionService;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.Assert;
//import org.springframework.boot.context.properties.bind.convert.BinderConversionService;
/**
* A {@link Map} implementation that initializes its entries by binding values from the
* supplied environment. Any call to 'get()' will result in either returning the existing

View File

@@ -65,7 +65,6 @@ public interface MergableProperties {
Object value = readMethod.invoke(this);
if (value != null) {
if (value instanceof MergableProperties) {
Object m = readMethod.invoke(mergable);
((MergableProperties)value).merge((MergableProperties)readMethod.invoke(mergable));
}
else {

View File

@@ -62,7 +62,7 @@ public class AbstractMessageChannelBinderTests {
}
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
@SuppressWarnings("unchecked")
public void testEndpointLifecycle() throws Exception {
AbstractMessageChannelBinder<ConsumerProperties, ProducerProperties, ProvisioningProvider<ConsumerProperties, ProducerProperties>> binder =
context.getBean(AbstractMessageChannelBinder.class);
@@ -106,7 +106,7 @@ public class AbstractMessageChannelBinderTests {
}
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
@SuppressWarnings("unchecked")
public void testEndpointBinderHasRecoverer() throws Exception {
ConfigurableApplicationContext context =
new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration()).web(WebApplicationType.NONE).run();