Comments (3)
Ok. I'll make the method protected.
Which other methods do you think will be helpful for the extension ?
from jinstagram.
Great, thanks
I have made some modifications through inheritance which could go into Instagram.java
generic way to create new objects, makes it easy to create your own model. This method don't need reflection when it can access the createInstagramObject method.
@SuppressWarnings("unchecked")
public <T extends InstagramObject> T fetchObject(String path, Class<T> type, Parameter... params) throws InstagramException {
Map<String, String> paramMap = new HashMap<String, String>();
for (Parameter p : params) {
paramMap.put(p.getKey(), p.getValue().toString());
}
T result = null;
try {
result = (T)createInstagramObjectMethod.invoke(this, Verbs.GET, type, path, paramMap);
} catch (InvocationTargetException e) {
if (e.getCause() != null && e.getCause() instanceof InstagramException) {
throw (InstagramException)e.getCause();
} else {
throw new RuntimeException(e);
}
} catch (IllegalAccessException | IllegalArgumentException e) {
throw new RuntimeException(e);
}
return result;
}
A generic getNextPage method
@SuppressWarnings("unchecked")
public <T extends InstagramObject> T getNextPage(Pagination pagination, Class<T> type) throws InstagramException {
T result = null;
try {
result = (T)createInstagramObjectMethod.invoke(this, Verbs.GET, type, StringUtils.removeStart(pagination.getNextUrl(), getInstagramConfig().getApiURL()), null);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new RuntimeException(e);
}
return result;
}
Finally it would be nice if the generics in the model objects such as List<MediaFeedData> data
was parameterized with a wildcard so we get List<? extends MediaFeedData> data
. This will make the extension of the existing model possible. (the getters and setters should also have ? extends XXX
)
from jinstagram.
Closing the ticket... Re-open if needed
from jinstagram.
Related Issues (20)
- Placeholder for Maven release HOT 1
- Matching code was not found or was already used HOT 4
- oEmbed endpoint does not give html of embed HOT 1
- Is the project still maintained? Getting errors on most functions. HOT 2
- Verifier HOT 1
- oEmbed wrong api endpoint
- How to get list of following users of an profile? HOT 2
- Isnt the sex info available? HOT 1
- getMediaByTagsSpecialCharacter (org.jinstagram.InstagramTest) - jUnit Test Failing
- How to get multiple images in one post? HOT 6
- About user verified. HOT 1
- How to persist the authentication for later use?
- Constant type carousel - MediaFeedData.CAROUSEL HOT 1
- Release 1.2.2 HOT 2
- comments always null
- does not return more than the media HOT 1
- Support for GraphAPI? HOT 4
- How do I upload a photo with Jinstagram?
- Error while accessing Access Token HOT 4
- fetch user stories HOT 1
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 jinstagram.