Skip to content

Commit ee79e07

Browse files
committed
Fixed checkstyle errors
Signed-off-by: leijendary <[email protected]>
1 parent 6e11ac5 commit ee79e07

File tree

8 files changed

+170
-96
lines changed

8 files changed

+170
-96
lines changed

spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/chat/memory/pgvector/PgVectorChatMemoryAutoConfiguration.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
/*
2-
* Copyright 2024 - 2024 the original author or authors.
2+
* Copyright 2024-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.ai.autoconfigure.chat.memory.pgvector;
1718

19+
import javax.sql.DataSource;
20+
1821
import org.springframework.ai.chat.memory.PgVectorChatMemory;
1922
import org.springframework.ai.chat.memory.PgVectorChatMemoryConfig;
2023
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -25,8 +28,6 @@
2528
import org.springframework.context.annotation.Bean;
2629
import org.springframework.jdbc.core.JdbcTemplate;
2730

28-
import javax.sql.DataSource;
29-
3031
/**
3132
* @author Jonathan Leijendekker
3233
* @since 1.0.0

spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/chat/memory/pgvector/PgVectorChatMemoryProperties.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
/*
2-
* Copyright 2024 - 2024 the original author or authors.
2+
* Copyright 2024-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.ai.autoconfigure.chat.memory.pgvector;
1718

1819
import org.springframework.ai.autoconfigure.chat.memory.CommonChatMemoryProperties;
@@ -41,47 +42,47 @@ public class PgVectorChatMemoryProperties extends CommonChatMemoryProperties {
4142
private String userColumnName = PgVectorChatMemoryConfig.DEFAULT_USER_COLUMN_NAME;
4243

4344
public String getSchemaName() {
44-
return schemaName;
45+
return this.schemaName;
4546
}
4647

4748
public void setSchemaName(String schemaName) {
4849
this.schemaName = schemaName;
4950
}
5051

5152
public String getTableName() {
52-
return tableName;
53+
return this.tableName;
5354
}
5455

5556
public void setTableName(String tableName) {
5657
this.tableName = tableName;
5758
}
5859

5960
public String getSessionIdColumnName() {
60-
return sessionIdColumnName;
61+
return this.sessionIdColumnName;
6162
}
6263

6364
public void setSessionIdColumnName(String sessionIdColumnName) {
6465
this.sessionIdColumnName = sessionIdColumnName;
6566
}
6667

6768
public String getExchangeIdColumnName() {
68-
return exchangeIdColumnName;
69+
return this.exchangeIdColumnName;
6970
}
7071

7172
public void setExchangeIdColumnName(String exchangeIdColumnName) {
7273
this.exchangeIdColumnName = exchangeIdColumnName;
7374
}
7475

7576
public String getAssistantColumnName() {
76-
return assistantColumnName;
77+
return this.assistantColumnName;
7778
}
7879

7980
public void setAssistantColumnName(String assistantColumnName) {
8081
this.assistantColumnName = assistantColumnName;
8182
}
8283

8384
public String getUserColumnName() {
84-
return userColumnName;
85+
return this.userColumnName;
8586
}
8687

8788
public void setUserColumnName(String userColumnName) {

spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/chat/memory/pgvector/PgVectorChatMemoryAutoConfigurationIT.java

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
1+
/*
2+
* Copyright 2024-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.ai.autoconfigure.chat.memory.pgvector;
218

19+
import java.util.List;
20+
import java.util.UUID;
21+
322
import org.junit.jupiter.api.Test;
23+
import org.testcontainers.containers.PostgreSQLContainer;
24+
import org.testcontainers.junit.jupiter.Container;
25+
import org.testcontainers.junit.jupiter.Testcontainers;
26+
427
import org.springframework.ai.chat.memory.PgVectorChatMemory;
528
import org.springframework.ai.chat.messages.AssistantMessage;
629
import org.springframework.ai.chat.messages.Message;
@@ -9,12 +32,6 @@
932
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
1033
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
1134
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
12-
import org.testcontainers.containers.PostgreSQLContainer;
13-
import org.testcontainers.junit.jupiter.Container;
14-
import org.testcontainers.junit.jupiter.Testcontainers;
15-
16-
import java.util.List;
17-
import java.util.UUID;
1835

1936
import static org.assertj.core.api.Assertions.assertThat;
2037

@@ -42,7 +59,7 @@ class PgVectorChatMemoryAutoConfigurationIT {
4259

4360
@Test
4461
void addGetAndClear_shouldAllExecute() {
45-
contextRunner.run(context -> {
62+
this.contextRunner.run(context -> {
4663
var chatMemory = context.getBean(PgVectorChatMemory.class);
4764
var conversationId = UUID.randomUUID().toString();
4865
var userMessage = new UserMessage("Message from the user");
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1+
/*
2+
* Copyright 2024-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.ai.autoconfigure.chat.memory.pgvector;
218

319
import org.junit.jupiter.api.Test;
20+
421
import org.springframework.ai.chat.memory.PgVectorChatMemoryConfig;
522

6-
import static org.junit.jupiter.api.Assertions.*;
23+
import static org.assertj.core.api.Assertions.assertThat;
724

825
/**
926
* @author Jonathan Leijendekker
@@ -13,13 +30,13 @@ class PgVectorChatMemoryPropertiesTests {
1330
@Test
1431
void defaultValues() {
1532
var props = new PgVectorChatMemoryProperties();
16-
assertEquals(PgVectorChatMemoryConfig.DEFAULT_SCHEMA_NAME, props.getSchemaName());
17-
assertEquals(PgVectorChatMemoryConfig.DEFAULT_TABLE_NAME, props.getTableName());
18-
assertEquals(PgVectorChatMemoryConfig.DEFAULT_SESSION_ID_COLUMN_NAME, props.getSessionIdColumnName());
19-
assertEquals(PgVectorChatMemoryConfig.DEFAULT_EXCHANGE_ID_COLUMN_NAME, props.getExchangeIdColumnName());
20-
assertEquals(PgVectorChatMemoryConfig.DEFAULT_ASSISTANT_COLUMN_NAME, props.getAssistantColumnName());
21-
assertEquals(PgVectorChatMemoryConfig.DEFAULT_USER_COLUMN_NAME, props.getUserColumnName());
22-
assertTrue(props.isInitializeSchema());
33+
assertThat(props.getSchemaName()).isEqualTo(PgVectorChatMemoryConfig.DEFAULT_SCHEMA_NAME);
34+
assertThat(props.getTableName()).isEqualTo(PgVectorChatMemoryConfig.DEFAULT_TABLE_NAME);
35+
assertThat(props.getSessionIdColumnName()).isEqualTo(PgVectorChatMemoryConfig.DEFAULT_SESSION_ID_COLUMN_NAME);
36+
assertThat(props.getExchangeIdColumnName()).isEqualTo(PgVectorChatMemoryConfig.DEFAULT_EXCHANGE_ID_COLUMN_NAME);
37+
assertThat(props.getAssistantColumnName()).isEqualTo(PgVectorChatMemoryConfig.DEFAULT_ASSISTANT_COLUMN_NAME);
38+
assertThat(props.getUserColumnName()).isEqualTo(PgVectorChatMemoryConfig.DEFAULT_USER_COLUMN_NAME);
39+
assertThat(props.isInitializeSchema()).isTrue();
2340
}
2441

2542
@Test
@@ -33,13 +50,13 @@ void customValues() {
3350
props.setUserColumnName("custom_user_column_name");
3451
props.setInitializeSchema(false);
3552

36-
assertEquals("custom_schema_name", props.getSchemaName());
37-
assertEquals("custom_table_name", props.getTableName());
38-
assertEquals("custom_session_id_column_name", props.getSessionIdColumnName());
39-
assertEquals("custom_exchange_id_column_name", props.getExchangeIdColumnName());
40-
assertEquals("custom_assistant_column_name", props.getAssistantColumnName());
41-
assertEquals("custom_user_column_name", props.getUserColumnName());
42-
assertFalse(props.isInitializeSchema());
53+
assertThat(props.getSchemaName()).isEqualTo("custom_schema_name");
54+
assertThat(props.getTableName()).isEqualTo("custom_table_name");
55+
assertThat(props.getSessionIdColumnName()).isEqualTo("custom_session_id_column_name");
56+
assertThat(props.getExchangeIdColumnName()).isEqualTo("custom_exchange_id_column_name");
57+
assertThat(props.getAssistantColumnName()).isEqualTo("custom_assistant_column_name");
58+
assertThat(props.getUserColumnName()).isEqualTo("custom_user_column_name");
59+
assertThat(props.isInitializeSchema()).isFalse();
4360
}
4461

4562
}

vector-stores/spring-ai-pgvector-store/src/main/java/org/springframework/ai/chat/memory/PgVectorChatMemory.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
/*
2-
* Copyright 2024 - 2024 the original author or authors.
2+
* Copyright 2024-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.ai.chat.memory;
1718

19+
import java.sql.PreparedStatement;
20+
import java.sql.ResultSet;
21+
import java.sql.SQLException;
22+
import java.sql.Types;
23+
import java.util.List;
24+
1825
import org.springframework.ai.chat.messages.AssistantMessage;
1926
import org.springframework.ai.chat.messages.Message;
2027
import org.springframework.ai.chat.messages.UserMessage;
2128
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
2229
import org.springframework.jdbc.core.JdbcTemplate;
2330
import org.springframework.jdbc.core.RowMapper;
2431

25-
import java.sql.PreparedStatement;
26-
import java.sql.ResultSet;
27-
import java.sql.SQLException;
28-
import java.sql.Types;
29-
import java.util.List;
30-
3132
/**
3233
* An implementation of {@link ChatMemory} for PgVector. Creating an instance of
3334
* PgVectorChatMemory example:

vector-stores/spring-ai-pgvector-store/src/main/java/org/springframework/ai/chat/memory/PgVectorChatMemoryConfig.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
/*
2-
* Copyright 2024 - 2024 the original author or authors.
2+
* Copyright 2024-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.ai.chat.memory;
1718

1819
import org.slf4j.Logger;
1920
import org.slf4j.LoggerFactory;
21+
2022
import org.springframework.jdbc.core.JdbcTemplate;
2123
import org.springframework.util.Assert;
2224

2325
/**
2426
* @author Jonathan Leijendekker
2527
* @since 1.0.0
2628
*/
27-
public class PgVectorChatMemoryConfig {
29+
public final class PgVectorChatMemoryConfig {
2830

2931
private static final Logger logger = LoggerFactory.getLogger(PgVectorChatMemoryConfig.class);
3032

@@ -136,7 +138,7 @@ void initializeSchema() {
136138
this.getFullyQualifiedTableName(), this.getSessionIdColumnName(), this.getExchangeIdColumnName()));
137139
}
138140

139-
public static class Builder {
141+
public static final class Builder {
140142

141143
private boolean initializeSchema = DEFAULT_SCHEMA_INITIALIZATION;
142144

@@ -212,7 +214,7 @@ public Builder withJdbcTemplate(JdbcTemplate jdbcTemplate) {
212214
}
213215

214216
public PgVectorChatMemoryConfig build() {
215-
Assert.notNull(jdbcTemplate, "jdbc template must not be null");
217+
Assert.notNull(this.jdbcTemplate, "jdbc template must not be null");
216218

217219
return new PgVectorChatMemoryConfig(this);
218220
}

0 commit comments

Comments
 (0)