Skip to content

Code Cleanup - StringBuilder, Redundant Iteration, Record #3016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
* @author Soby Chacko
* @author Byungjun You
* @author Georg Friedrich
* @author Omer Celik
* @since 2.2.0
*/
public class KafkaStreamsFunctionProcessor extends AbstractKafkaStreamsBinderProcessor implements BeanFactoryAware {
Expand Down Expand Up @@ -475,7 +476,7 @@ private void handleKStreamArrayOutbound(ResolvableType resolvableType, String fu
String next = iterator.next();
kafkaStreamsBindableProxyFactory.addOutputBinding(next, KStream.class);
RootBeanDefinition rootBeanDefinition1 = new RootBeanDefinition();
rootBeanDefinition1.setInstanceSupplier(() -> kafkaStreamsBindableProxyFactory.getOutputHolders().get(next).getBoundTarget());
rootBeanDefinition1.setInstanceSupplier(() -> kafkaStreamsBindableProxyFactory.getOutputHolders().get(next).boundTarget());
registry.registerBeanDefinition(next, rootBeanDefinition1);

Object targetBean = this.applicationContext.getBean(next);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 the original author or authors.
* Copyright 2019-2024 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.
Expand Down Expand Up @@ -65,6 +65,7 @@
* the actual size in the returned array. That has to wait until the function is invoked and we get a result.
*
* @author Soby Chacko
* @author Omer Celik
* @since 3.0.0
*/
public class KafkaStreamsBindableProxyFactory extends AbstractBindableProxyFactory implements InitializingBean, BeanFactoryAware {
Expand Down Expand Up @@ -173,7 +174,7 @@ public void afterPropertiesSet() {
.createOutput(outputBinding), true));
String outputBinding1 = outputBinding;
RootBeanDefinition rootBeanDefinition1 = new RootBeanDefinition();
rootBeanDefinition1.setInstanceSupplier(() -> outputHolders.get(outputBinding1).getBoundTarget());
rootBeanDefinition1.setInstanceSupplier(() -> outputHolders.get(outputBinding1).boundTarget());
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
registry.registerBeanDefinition(outputBinding1, rootBeanDefinition1);
}
Expand Down Expand Up @@ -248,7 +249,7 @@ private void bindInput(ResolvableType arg0, String inputName) {
}
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
RootBeanDefinition rootBeanDefinition = new RootBeanDefinition();
rootBeanDefinition.setInstanceSupplier(() -> inputHolders.get(inputName).getBoundTarget());
rootBeanDefinition.setInstanceSupplier(() -> inputHolders.get(inputName).boundTarget());
registry.registerBeanDefinition(inputName, rootBeanDefinition);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-2024 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.
Expand Down Expand Up @@ -35,6 +35,7 @@
*
* Original authors in {@link BindableProxyFactory}
* @author Soby Chacko
* @author Omer Celik
* @since 3.0.0
*/
public class AbstractBindableProxyFactory implements Bindable {
Expand Down Expand Up @@ -94,9 +95,9 @@ public Collection<Binding<Object>> createAndBindInputs(
.entrySet()) {
String inputTargetName = boundTargetHolderEntry.getKey();
BoundTargetHolder boundTargetHolder = boundTargetHolderEntry.getValue();
if (boundTargetHolder.isBindable()) {
if (boundTargetHolder.bindable()) {
bindings.addAll(bindingService.bindConsumer(
boundTargetHolder.getBoundTarget(), inputTargetName));
boundTargetHolder.boundTarget(), inputTargetName));
}
}
return bindings;
Expand All @@ -111,9 +112,9 @@ public Collection<Binding<Object>> createAndBindOutputs(
.entrySet()) {
BoundTargetHolder boundTargetHolder = boundTargetHolderEntry.getValue();
String outputTargetName = boundTargetHolderEntry.getKey();
if (boundTargetHolderEntry.getValue().isBindable()) {
if (boundTargetHolderEntry.getValue().bindable()) {
bindings.add(bindingService.bindProducer(
boundTargetHolder.getBoundTarget(), outputTargetName));
boundTargetHolder.boundTarget(), outputTargetName));
}
}
return bindings;
Expand All @@ -123,7 +124,7 @@ public Collection<Binding<Object>> createAndBindOutputs(
public void unbindInputs(BindingService bindingService) {
for (Map.Entry<String, BoundTargetHolder> boundTargetHolderEntry : this.inputHolders
.entrySet()) {
if (boundTargetHolderEntry.getValue().isBindable()) {
if (boundTargetHolderEntry.getValue().bindable()) {
bindingService.unbindConsumers(boundTargetHolderEntry.getKey());
}
}
Expand All @@ -133,7 +134,7 @@ public void unbindInputs(BindingService bindingService) {
public void unbindOutputs(BindingService bindingService) {
for (Map.Entry<String, BoundTargetHolder> boundTargetHolderEntry : this.outputHolders
.entrySet()) {
if (boundTargetHolderEntry.getValue().isBindable()) {
if (boundTargetHolderEntry.getValue().bindable()) {
bindingService.unbindProducers(boundTargetHolderEntry.getKey());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2024 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.
Expand All @@ -24,25 +24,8 @@
*
* @author Original authors in {@link BindableProxyFactory}
* @author Soby Chacko
* @author Omer Celik
* @since 3.0.0
*/
public final class BoundTargetHolder {

private Object boundTarget;

private boolean bindable;

public BoundTargetHolder(Object boundTarget, boolean bindable) {
this.boundTarget = boundTarget;
this.bindable = bindable;
}

public Object getBoundTarget() {
return this.boundTarget;
}

public boolean isBindable() {
return this.bindable;
}

public record BoundTargetHolder(Object boundTarget, boolean bindable) {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2018 the original author or authors.
* Copyright 2015-2024 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.
Expand Down Expand Up @@ -148,16 +148,16 @@ public boolean onlyOneOfProducerOrConsumerSet() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("destination=" + this.destination);
sb.append("destination=").append(this.destination);
sb.append(COMMA);
sb.append("group=" + this.group);
sb.append("group=").append(this.group);
sb.append(COMMA);
if (this.contentType != null) {
sb.append("contentType=" + this.contentType);
sb.append("contentType=").append(this.contentType);
sb.append(COMMA);
}
if (this.binder != null) {
sb.append("binder=" + this.binder);
sb.append("binder=").append(this.binder);
sb.append(COMMA);
}
sb.deleteCharAt(sb.lastIndexOf(COMMA));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
* @author Oleg Zhurakousky
* @author Soby Chacko
* @author Chris Bono
* @author Omer Celik
*/
@AutoConfiguration
@EnableConfigurationProperties({ BindingServiceProperties.class,
Expand Down Expand Up @@ -132,6 +133,7 @@ public static Map<String, BinderConfiguration> getBinderConfigurations(
.entrySet()) {
if (configurationEntry.getValue().isDefaultCandidate()) {
defaultCandidatesExist = true;
break;
}
}
if (!defaultCandidatesExist) {
Expand Down
Loading