Comments (11)
@alexfu, that's what I normally do for methods exposed to an interface. We can create a separate class which is only responsible for validation or create a new interface containing a valid()
method which every builder should implement.
What do you think?
from sqlitequerybuilder.
You can use Preconditions for this.
public CreateTableBuilder column(Column column) {
Preconditions.checkNotNull(column, "A non-null column is required.");
definitions.add(column);
return this;
}
from sqlitequerybuilder.
Or we can use the Java Objects class instead of introducing new library.
public CreateTableBuilder column(Column column) {
Objects.requireNonNull(column, "A non-null column is required.");
definitions.add(column);
return this;
}
If the validation becomes more detailed and specific, then we need to create our own.
from sqlitequerybuilder.
Didn't know Objects had those checks. If It's just to check if an argument is null i agree.
Preconditions have other checks such as checkArgument(boolean expression)
and throws an IllegalArgumentException
accordingly.
It won't introduce another library, we can just include the Preconditions.java file (or just some methods) as it doesn't have any dependencies.
from sqlitequerybuilder.
Just noticed that in case of using on Android the Objects class is only available >= API 19
, so just a limitation there.
from sqlitequerybuilder.
Oops, it is a limitation. Use other available library or check null by yourself then.
What sort of android project are you working on at the moment?
from sqlitequerybuilder.
@shadeven just a personal app, ticket manager for train trips here in portugal. It only imports the tickets from pdfs that the company sends by email; notifies of the next trip with convenient information like gate, carriage and seat number.
from sqlitequerybuilder.
@monxalo, sounds interesting. I want to up-skill in android development area, please let me know if you need extra hands.
from sqlitequerybuilder.
I'm in favor for doing null checks by hand or use Assert.assertNotNull. Using a third party library like Guava brings in unnecessary code in addition to depending on yet another library.
from sqlitequerybuilder.
@alexfu Like i said above you don't need to add the library as a dependency, just add the file needed to the util package like u2020.
from sqlitequerybuilder.
@monxalo sorry, must of missed that. that works too.
from sqlitequerybuilder.
Related Issues (20)
- Support for other Join operators HOT 1
- Guide users into correct method calls
- Cannot call limit after where
- Support AUTOINCREMENT HOT 1
- Add checkstyle
- Support DEFAULT HOT 1
- Use package-private scope HOT 3
- Parse results HOT 5
- Support for insert and Update statements HOT 2
- Add information about licensing
- Can't use and method twice after where
- Can't provide auto increment primary key HOT 3
- Not possible to chain multiple join statements other than regular join HOT 2
- Use a real SQLite instance for testing
- Add a CHANGELOG
- Foreign keys HOT 5
- Chain order by to join HOT 3
- COUNT statement HOT 1
- Chain order by to join HOT 1
- Prepared statements
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlitequerybuilder.